//-------------link color
function ch(tt){
	tt.style.color="#295f37";
}
function ch1(tt){
	tt.style.color="#000000";
}


function forgetpass(){
//alert(wi+"-"+yt);
window.open('codepage/forgetpass.php','houhou','scrollbars=no,width=350,height=200');
}

function changepass(){
//alert(wi+"-"+yt);
window.open('codepage/changpass.php','houhou','scrollbars=no,width=350,height=200');
}

// JavaScript Document
function checkml(){
	em_val = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
	if(document.mlist.fn.value==""){
		alert("Please Enter Your Full Name");
		document.mlist.fn.focus();
		return false;
	} else if(em_val.test(document.mlist.ml.value)==false){
		alert("Invalid E-mail Address");
		document.mlist.ml.focus();
		//document.mlist.submitto.disabled= true;
		return false;
	} else {
		//document.mlist.submitto.disabled= false;
		//document.mlist.action="codepage/coding.php";
		document.mlist.submit();
	}
}

function checklogin(){
	if(document.login.uslog.value==""){
		alert("Please Enter Your Username");
		document.login.uslog.focus();
		return false;
	} else if(document.login.pslog.value==""){
		alert("Please Enter Your Password");
		document.login.pslog.focus();
		return false;
	} else {
		document.login.submit();
	}
}
function checkcontact(){
em_val = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
if(document.conta.ctfn.value==""){
alert("Enter Your Full Name");
document.conta.ctfn.focus();
} else if(document.conta.ctco.value==""){
alert("Enter Your Country");
document.conta.ctco.focus();
} else if (em_val.test(document.conta.ctml.value)==false){
alert("Invalid E-mail Address");
document.conta.ctml.focus();
} else if(document.conta.ctme.value==""){
alert("Write The Message");
document.conta.ctme.focus();
} else {
document.conta.submit();
}
}

function checkorder(){
em_val = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
if(document.conta.ctfn.value==""){
alert("Enter Your Full Name");
document.conta.ctfn.focus();
//} else if(document.conta.compname.value==""){
//alert("Enter Your Company Name");	
} else if (em_val.test(document.conta.ctml.value)==false){
alert("Invalid E-mail Address");
document.conta.ctml.focus();
} else if(document.conta.ctph.value==""){
alert("Enter Your Phone Number");
document.conta.ctph.focus();
} else if(document.conta.ctme.value==""){
alert("Write The Order");
document.conta.ctme.focus();
} else {
document.conta.submit();
}
}

function checkmembers(){
	em_val = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
	if(document.members.mfn.value==""){
	alert("Enter Your Full Name");
	} else if(document.members.age.value=="0"){
	alert("Enter Your Age");
	} else if(document.members.mco.value==""){
	alert("Enter Your Nationality");
	} else if (em_val.test(document.members.mml.value)==false){
	alert("Invalid E-Mail Address");
	} else if(document.members.mph.value==""){
	alert("Enter Your Phone Number");
	} else if(document.members.status.value=="0"){
	alert("Select Status");
	} else if(document.members.study.value=="0"){
	alert("Select Your Study");
	} else {
	document.members.submit();
	}
}

//-------Guestbook
function addgbval() {
em_val = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
 if( (document.topicadd.title.value=="") || (document.topicadd.fn.value=="") || (document.topicadd.ml.value=="")) {
	 alert("Please write information");
	 return;}
	 else if( (topicadd.topic.value == "") || (topicadd.topic.innerHTML == "Write your text here") ) {
		 alert("Please Enter Your text");
		 return;
		 } else if(em_val.test(document.topicadd.ml.value)==false){
		 alert("invalid email address")
		return (false);
 } else {
	 document.topicadd.submit();
	 return; }
}

function checkmax(we){
	if(document.topicadd.topic.value.length<300){
		//document.addnews.max1.value =200-(document.addnews.description.value.length+1);
		document.getElementById("max2").innerHTML= 300-(document.topicadd.topic.value.length+1);
	}  
	if(document.topicadd.topic.value=="") {
		//document.addnews.max1.value= 200;
		document.getElementById("max2").innerHTML= 300
	} 
}


function checkmax1(we){
	if(document.topicadd.title.value.length<18){
		//document.addnews.max1.value =200-(document.addnews.description.value.length+1);
		document.getElementById("max3").innerHTML= 18-(document.topicadd.title.value.length+1);
	}  
	if(document.topicadd.title.value=="") {
		//document.addnews.max1.value= 200;
		document.getElementById("max3").innerHTML= 18
	} 
}


function cf(){
	if(document.topicadd.topic.innerHTML=="??EE C?E????"){
		document.topicadd.topic.innerHTML= "";
	} else {
		document.getElementById("max2").innerHTML=300-(document.topicadd.topic.value.length);
	}
}
//------------------------------
function got6776(yt,wi,hi,houhou,hihi,cato){
//alert(wi+"-"+yt);
window.open('viewimg.php?sid='+yt+'&imid='+houhou+'&cato='+cato+'&catoid='+hihi,houhou,'scrollbars=no,width='+wi+',height='+hi);
}

function got(yt,wi,hi,idd){
	hie=Number(hi)+90;
	wie=Number(wi)+18;
//alert(hie);
window.open('codepage/viewimg.php?img='+yt+'&id='+idd,''+idd+'','scrollbars=yes,width='+wie+',height='+hie);
}

function profile(yt){

window.open('codepage/profile.php?id='+yt,'profile','scrollbars=no,width=500,height=400');
}

//////
function getRandomNum(lbound, ubound) {
return (Math.floor(Math.random() * (ubound - lbound)) + lbound);
}
function getRandomChar(lower) {
var lowerChars = "abcdefghijklmnopqrstuvwxyz";
var charSet = "";
if (lower == true)
charSet += lowerChars;
return charSet.charAt(getRandomNum(0, charSet.length));
}
function getPassword(length) {
var rc = "";
if (length > 0)
rc = rc + getRandomChar();
for (var idx = 1; idx < length; ++idx) {
rc = rc + getRandomChar(true);
}
return rc;
}
function activec() {
document.newuser.activecode.value =getPassword(10);
}
//---------------------end random password-------------------
function checknewuser(){
em_val = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
if(document.newuser.usern.value==""){
alert("Enter Username");
} else if(document.newuser.usern.value.length<6){
alert("Username may be minimum 6 characters");
} else if(document.newuser.passn.value==""){
alert("Enter Password");
} else if(document.newuser.passn.value.length<6){
alert("Password may be minimum 6 characters");
} else if(document.newuser.passn.value != document.newuser.cpassn.value){
alert("Confirm Password");
} else if(document.newuser.fname.value==""){
alert("Enter Your First Name");
//} else if(document.newuser.lname.value==""){
//alert("Enter Your Last Name");
//} else if(document.newuser.jobt.value==""){
//alert("Enter Your Job Title");
//} else if(document.newuser.comname.value==""){
//alert("Enter Your Company Name");
} else if(document.newuser.country.value==""){
alert("Enter Country");
} else if(document.newuser.pnumber.value=="" && document.newuser.mnumber.value==""){
alert("Enter Your Phone or Mobile Number");
//} else if(document.newuser.mnumber.value==""){
//alert("Enter Your Mobile Number");
//} else if(document.newuser.mnumber.value==""){
//alert("Enter Your Mobile Number");
} else if(em_val.test(document.newuser.umail.value)==false){
alert("Invalid E-mail Address");
} else {
document.newuser.submit();
}
}



function checkupuser(){
em_val = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
if(document.newuser.usern.value==""){
alert("Enter Username");
} else if(document.newuser.fname.value==""){
alert("Enter Your First Name");
} else if(document.newuser.country.value==""){
alert("Enter Country");
} else if(document.newuser.pnumber.value=="" && document.newuser.mnumber.value==""){
alert("Enter Your Phone or Mobile Number");
} else if(em_val.test(document.newuser.umail.value)==false){
alert("Invalid E-mail Address");
} else {
document.newuser.submit();
}
}


