// JavaScript Document
function changeMenu(id,mid){
	if(document.getElementById("Menu"+mid)){
		document.getElementById("Menu"+mid).src="img/"+id+"_s.gif";
		if(document.getElementById("Sep"+(mid-1)))
			document.getElementById("Sep"+(mid-1)).src="img/trans.gif";
		if(document.getElementById("Sep"+mid))
			document.getElementById("Sep"+mid).src="img/trans.gif";
	}	
}
function resetMenu(id,mid){
	if(document.getElementById("Menu"+mid)){
		document.getElementById("Menu"+mid).src="img/"+id+".gif";
		if(document.getElementById("Sep"+(mid-1)))
			document.getElementById("Sep"+(mid-1)).src="img/m_sep.gif";
		if(document.getElementById("Sep"+mid))
			document.getElementById("Sep"+mid).src="img/m_sep.gif";
	}
}
function resetMenuprev(id,mid){
	if(document.getElementById("Menu"+mid)){
		document.getElementById("Menu"+mid).src="img/"+id+".gif";
		if(document.getElementById("Sep"+(mid-1)))
			document.getElementById("Sep"+(mid-1)).src="img/m_sep.gif";
		if(document.getElementById("Sep"+mid))
			document.getElementById("Sep"+mid).src="img/trans.gif";
	}
}
function resetMenunext(id,mid){
	if(document.getElementById("Menu"+mid)){
		document.getElementById("Menu"+mid).src="img/"+id+".gif";
		if(document.getElementById("Sep"+(mid-1)))
			document.getElementById("Sep"+(mid-1)).src="img/trans.gif";
		if(document.getElementById("Sep"+mid))
			document.getElementById("Sep"+mid).src="img/m_sep.gif";
	}
}
// Dynamic Contact Changes	
var preVal="";
function expandContent(id)
{  		
	if(preVal!="" && preVal!=id)
	{
		document.getElementById("w"+preVal).className="text_hidden";
		preVal="";
	}
	val=((document.getElementById("w"+id).className)=="text_hidden")? true:false;
	if(val)
	{
		document.getElementById("w"+id).className="text_visible";
	}
	else
	{
		document.getElementById("w"+id).className="text_hidden";
	}
	preVal=id;
}


var preVal="";
function expandContentBold(id)
{  	
	if(preVal!="" && preVal!=id)
	{
		document.getElementById("bullet_"+preVal).src="img/info_on.gif";
		document.getElementById("a"+preVal).className="normal";
		document.getElementById("w"+preVal).className="text_hidden";
		document.getElementById("awb10").className="text_hidden";
		document.getElementById("ab10").style.color="#098F1C";
		preVal="";
	}
	val=((document.getElementById("w"+id).className)=="text_hidden")? true:false;
	if(val)
	{
		document.getElementById("bullet_"+id).src="img/info_off.gif";
		document.getElementById("a"+id).className="hand";
		document.getElementById("w"+id).className="text_visible";
		document.getElementById("awb10").className="text_hidden";
		document.getElementById("ab10").style.color="#098F1C";
	}
	else
	{
		document.getElementById("bullet_"+id).src="img/info_on.gif";
		document.getElementById("a"+preVal).className="normal";
		document.getElementById("w"+id).className="text_hidden";
		document.getElementById("awb10").className="text_hidden";
		document.getElementById("ab10").style.color="#098F1C";
	}
	preVal=id;
}

var preVal1="";
function expandContentheading(id)
{  
	if(preVal1!="" && preVal1!=id)
	{
		document.getElementById("aw"+preVal1).className="text_hidden";
		document.getElementById("a"+id).style.color="#FF6600";
		preVal1="";
	}
	val=((document.getElementById("aw"+id).className)=="text_hidden")? true:false;
	if(val)
	{
		document.getElementById("aw"+id).className="text_visible";
		document.getElementById("a"+id).style.color="#098F1C";
	}
	else
	{
		document.getElementById("aw"+id).className="text_hidden";
		document.getElementById("a"+id).style.color="#D34D41";
	}
	preVal1=id;
}

var preVal2="";
function expandContentAnchoreBold(id)
{  	
	if(preVal2!="" && preVal2!=id)
	{
		document.getElementById("bullet_"+preVal2).src="img/info_on.gif";
		document.getElementById("a"+preVal2).className="normal";
		document.getElementById("w"+preVal2).className="text_hidden";
		preVal2="";
	}
	val=((document.getElementById("w"+id).className)=="text_hidden")? true:false;
	if(val)
	{
		document.getElementById("bullet_"+id).src="img/info_off.gif";
		document.getElementById("a"+id).className="hand";
		document.getElementById("w"+id).className="text_visible";
		
	}
	else
	{
		document.getElementById("bullet_"+id).src="img/info_on.gif";
		document.getElementById("a"+preVal2).className="normal";
		document.getElementById("w"+id).className="text_hidden";
	}
	preVal2=id;
}
/**  Alert Message */
function alert_error(msg)
{
	var obj=document.getElementById("error_msg");
	obj.innerHTML=msg;
}

// Remove the empty space
function trim(String)
{
   if (String == null)
   {   
   	return ("");
   }
   return String.replace(/(^\s+)|(\s+$)/g,"");
}
// Check Text or Not
function isText(str)
{
	var i=0;
	if(str.charAt(0)==' ')i++;
	while(i<str.length)
	{
		if (str.charAt(i)>='0' && str.charAt(i)<= '9' || str.charAt(i)=='+' || str.charAt(i)=='-' || str.charAt(i)=='*' || str.charAt(i)=='/' || str.charAt(i)=='\\' || str.charAt(i)=='\'' || str.charAt(i)=='@' || str.charAt(i)=='!' || str.charAt(i)=='~' || str.charAt(i)=='`' || str.charAt(i)=='#' || str.charAt(i)=='$' || str.charAt(i)=='%' || str.charAt(i)=='^' || str.charAt(i)=='&' || str.charAt(i)=='(' || str.charAt(i)==')' || str.charAt(i)=='_' || str.charAt(i)=='=' || str.charAt(i)=='?' || str.charAt(i)=='.' || str.charAt(i)==',' || str.charAt(i)==';' || str.charAt(i)==':' || str.charAt(i)=='"' || str.charAt(i)=='{' || str.charAt(i)=='}' || str.charAt(i)=='[' || str.charAt(i)==']' || str.charAt(i)=='<' || str.charAt(i)=='>' || str.charAt(i)=='|')
		return false;
		i++;
	}
	return true;
}

// Check the E-Mail Id
function isMailid(str) 
{
	var emailPat = /^[\w-\.]+\@[\w\.-]+\.[a-z]{2,4}$/;
	var matchArray = str.match(emailPat);
		if (matchArray == null)
		{
		alert("Enter valid E-mail ID as username");
		return false;
		}
}

/** Login form validation */
function formValidation()
{
 document.login.username.value=trim(document.login.username.value);
	username=trim(document.login.username.value);
	if ((username==null)||(username==""))
	{
		alert("Enter username")
		document.login.username.focus()
		return false
	}
	if (isMailid(username)==false)
	{
		document.login.username.focus()
		return false
	}

	if(document.login.password.value=="")
	{
		alert("Please enter password");
		document.login.password.focus();
		return false;
	}
		document.login.submit();
		//foo();
		window.close();		
		window.open('http://www.evaluationz.com:8080/evaluationz/?username='+username+'&');
		//window.open('http://psq-poornima/evaluationz/username.htm?username='+username+'&');
		//window.open('http://psq-saravanan:8080/Evaluationz/?username='+username+'&');
		
	return true;
}


// Scrollable menu code
// This Script for to get Query String URL
var sqsParm = new Array();
function mqs()
{
var query = window.location.search.substring(1);
var parms = query.split('&');
for (var i=0; i<parms.length; i++) 
{
   var pos = parms[i].indexOf('=');
   if (pos > 0) 
   {
      var key = parms[i].substring(0,pos);
      var val = parms[i].substring(pos+1);
      sqsParm[key] = val;
    }
 }
   return sqsParm["id"];
}



var linx = new Array(
	'client_login.htm',
	'client_login.htm',
	'client_login.htm',
	'client_login.htm');

var old = 0;
var current = 0;

// IMAGE ROTATION SOURCE CODE START
function init_images()
{
	img1 = new Image();		
	img2 = new Image();		
	img3 = new Image();		
	img4 = new Image();	
	
	
	img1.src = 'img/role_img_01.gif';
	img2.src = 'img/role_img_02.gif';
	img3.src = 'img/role_img_03.gif';
	img4.src = 'img/role_img_04.gif';
	
	toggle = 1;
}
// Change the next images
function nextImg()
{
	switch(toggle)
	{
		case 1: document.getElementById("viewrep").src = img1.src;break;
		case 2: document.getElementById("viewrep").src = img2.src;break;
		case 3: document.getElementById("viewrep").src = img3.src;break;
		case 4: document.getElementById("viewrep").src = img4.src;break;
	}
}
// Time setting
function changeImg()
{
	if (toggle==4)
	{
		setTimeout('nextImg();controller();',1000);
	}
	else
	setTimeout('nextImg();controller();',5000);
}
// Rotation
function controller()
{
	toggle += 1;
	if (toggle == 5) toggle = 1;
	changeImg();
}
// IMAGE ROTATION SOURCE CODE END


function sendPage()
{

	location.href = linx[current];
}

function call(fn)
	{
		var w=350;
		var h=230;
		var viewimageWin = window.open(fn,'New_Window','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width='+w+',height='+h);
 		viewimageWin.moveTo(screen.availWidth/2-(w/2),screen.availHeight/2-(h/2));
	}
function foo() 
{
	self.resizeTo(screen.availWidth,screen.availHeight); 
	self.moveTo(0,0);
	/*window.toolbar.visible = true; 
    window.menubar.visible = true; 
    myWindow = window.open("","windowRef","width=" + width + ",height=" + height+",top=1,left=0,screenX=1,screenY=1");
    myWindow.location.href = "http://www.evaluationz.com:8080/evaluationz/loginAction.jsp";
    if (!myWindow.opener) myWindow.opener = self;	*/
}

function popwin(img,w,h){
var x1 = screen.width;
var y1 = screen.height;
var top = parseInt((y1 - h)/2);
var left = parseInt((x1 - w)/2);
window.open(img,'show','width='+w+',height='+h+',resizable=yes,scrollbars=yes,status=no,top='+top+',left='+left);
return false;
}

function popopen(img){
window.open(img,'imx','width=100,height=50,resizable=no,scrollbars=no,status=no,top=50,left=50');
return false;
}


function win(image,title,w,h) {

var x1 = screen.width;
var y1 = screen.height;
var top = parseInt((y1 - h)/2);
var left = parseInt((x1 - w)/2);

ww=w;
wh=h+20;
//alert(image+'\nTitle : '+title+'\nWidth x Height :'+w+' x '+h+'\n Screen Size :'+x1+' x '+y1+'\n'+ww+' - '+wh);

	show=window.open('','show','width='+ww+',height='+wh+',resizable=no,scrollbars=no,status=no,top='+top+',left='+left);
	show.document.write('<html><head><title>Cicadamedia '+title+'</title>');
	show.document.write('<link rel="stylesheet" href="sns/styles.css"></head>');
	show.document.write('<body topmargin="0" leftmargin="0" marginwidth="0" bgcolor="#eeeeee" onload="window.focus();">');
	show.document.write('<table cellpadding="0" cellspacing="0" border="0" width="100%">');
	show.document.write('<tr><td><a href="javascript:window.close();"><img src="images/'+image+'.jpg" width="'+w+'" height="'+h+'" border="0"></a></td></tr>');
	show.document.write('<tr><td class="sbl" align="center" height="25"><a href="javascript:window.close();">Close this window</a></td></tr>');
	show.document.write('</table></body></html>');
}
