//-------------link color
function ch(tt){
	tt.style.color="#5e7f97";
}
function ch1(tt){
	tt.style.color="#FFFFFF";
}


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');
}
function checkask(){
	em_val = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
	if(document.ask.fname.value==""){
		alert("Please Enter your first name");
		document.ask.fname.focus();
	} else if(document.ask.lname.value==""){
		alert("Please Enter your last name");
		document.ask.lname.focus();
	} else if(document.ask.company.value==""){
		alert("Please Enter your company name");
		document.ask.company.focus();
	} else if(document.ask.tel.value==""){
		alert("Please Enter your Telaphone number");
		document.ask.tel.focus();
	} else if(em_val.test(document.ask.mailu.value)==false) {
		alert("Invalid E-mail Address");
		document.ask.mailu.focus();
	} else if(document.ask.comments.value==""){
		alert("Please Write Your Question/Comments");
		document.ask.comments.focus();
	} else {
		document.ask.submit();
	}
}
// 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();
}
}

// jobs function
function checkmembers(){
	em_val = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
	if(document.members.fn.value==""){
	alert("Enter Your Full Name");
	document.members.fn.focus();
	} else if(document.members.placeb.value==""){
	alert("Enter Your Place Of Birth");
	document.members.placeb.focus();
	} else if(document.members.dateb.value==""){
	alert("Enter Your Date Of Birth");
	document.members.dateb.focus();
	} else if(document.members.natio.value==""){
	alert("Enter Your Nationality");
	document.members.natio.focus();
	} else if(document.members.presaddress.value==""){
	alert("Enter Your Present Address");
	document.members.presaddress.focus();
	} else if (em_val.test(document.members.mailo.value)==false){
	alert("Invalid E-Mail Address");
	document.members.mailo.focus();
	} else if(document.members.pnum.value==""){
	alert("Enter Your Phone Number");
	document.members.pnum.focus();
	} 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)+18;
	wie=Number(wi)+18;
//alert(hie);
window.open('codepage/viewimg.php?img='+yt+'&id='+idd,'imgbiggo','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();
}
}
//
// voting
function checkvote(){
	var rad=document.vtse.elements.length;
	
	var c=0;
	for(i=0;i<rad;i++){
		if(document.vtse.elements[i].checked==true){
			var c=c+1;
		}
	}
	if(c==1){
		document.vtse.submit();
	} else {
		alert("Please Select answer");
	}
}

function voteresult(){
	window.open('codepage/voteresult.php','aboutus','scrollbars=yes,width=300,height=400');
}

function voteresultall(){
	window.open('codepage/voteresultall.php','aboutus','scrollbars=yes,width=300,height=400');
}



