/* $Id: site24x7.js,v 1.7 2009/10/30 13:32:13 sathya.cv Exp $ */
// JavaScript Document



var i = 0;
var counteri = 1;



function slideshow(){
showtime = setInterval("change()", 15000);
}

function change(){
if(document.getElementById('content1'))
{
document.getElementById('content1').innerHTML=pix[i];
i = i + 1;
if (i > (pix.length - 1)) {i = 0; counteri = counteri + 1;}
}
}

function setDefault()
                {
			if(document.mainform)
			{
				document.mainform.j_username.focus();
			}
                        fnTestimonial();
		}

function submittestimonial()
{
	    window.open( '../website/submittestimonial.jsp',this.target,'scrollbars=no,resizable=no,width=480,height=280');

}

function tellFriend()
{
            window.open( '../website/tellFriend.jsp',this.target,'scrollbars=no,resizable=no,width=520,height=350');

}


function reportAbuse()
{
   window.open( '../website/reportabuse.jsp',this.target,'scrollbars=no,resizable=yes,width=480,height=380');
}


function fnTestimonial()
{

	//getHtml('../website/rotate.html',"posttestimonial")
	slideshow();

	
}
/*function posttestimonial(result)
{

var divele = document.getElementById("testimonialdiv");
divele.innerHTML = result;
}*/

function fnLinkToUs()
{

	getHtml('/website/link-to-site24x7.html',"postLinkToUs")

	
}
function postLinkToUs(result)
{

var divele = document.getElementById("postLinkToUsdiv");
divele.innerHTML = result;
 
}
function focusUserID(){
	
	document.mainform.j_username.select();
}

function validateUser(Val)
{
setSecureCookie(Val);
if((document.mainform.j_username.value)== '')
{
	alert("EMail cannot be empty");
	return false;
}
else if((document.mainform.j_password.value)== '')
{
	alert("Password cannot be empty");
	return false;
	
}

if(document.mainform.j_username.value == 'admin')
{
	document.mainform.target="_top";
}

}

var today = new Date();
var expires = new Date(today.getTime() + (56 * 86400000));

function feedback()
{
window.open( '../login/feedback2.jsp', this.target,'scrollbars=no,resizable=no,width=480,height=250'); 

}
// ScrollEffect.lengthcount=10;

function validate() {
        if (!emptyCheck("j_username","Login ID"))
        return false

        if (!emptyCheck("j_password","Password"))
        return false

document.mainform.submit();
        }
function validateUserName(frm)
{
	alert("Franklin");
getHtml('../login/UserAction.do?execute=checkUser&name='+frm.loginName.value,"fnuserstatus")
}
function fnuserstatus(result)
{
	

userexists=""

if(result.indexOf("</success>")!=-1)
{
userexists="true";
}
else if(result.indexOf("valid=\"deactivated\"")!=-1)
{

	userexists="deactivated";
}
	//userexists = list.getAttribute('valid')
	
	if(userexists=='true')
	{
	
		var msgdiv = document.getElementById("usermsg");
		msgdiv.innerHTML="<span class='errormessage'>EMail is already registered</span>";
	}
	else if(userexists=='deactivated')
		{
		
			var msgdiv = document.getElementById("usermsg");
			msgdiv.innerHTML="<span class='errormessage'>EMail is already registered & deactivated</span>";
	}
	else
	{
	
		fieldvalidate();
	}
}
function getBrowserTimeZone()
{
var d = new Date();
d.setMonth(11);
var mins = d.getTimezoneOffset();
mins = parseInt(mins)* -1;
var hr = mins/60;
hr = parseInt(hr);
var min = mins%60;
min = parseInt(min);
alert(min);
if(min<0)
{
	min=min * -1;
}
if(min==0)
{
min='00';
}
alert(min);
return "(GMT "+(hr) +":"+min+")"

}        
function fnSubmitFeedBack(frm)
{
	if(frm.support.value=='')
	{
		alert("Please provide your feedback");
		return;
	}
	getHtmlForForm(frm,"postFeedBackSubmit");
	frm.reset();
}
function postFeedBackSubmit(a)
{

	var fdback = document.getElementById("feedbackmsg");
	fdback.innerHTML="<span class='errormessage'>Thanks for your Feedback</span>";
}


function setupRegister()
{
       
	hideAllLoginDivs();
       SIGN_UP.className="";
       NEW_USER_EMAIL.className = "";
       NEW_PASSWORD.className = "";
       CONFIRM_PASSWORD.className="";
       SUBMIT_ROW.className = "";
       AGREE.className = "";
       signUpForm.loginName.focus();
}


function showTermsOfService()
{
	centrePopup('http://www.site24x7.com/website/terms.html', 'new', '700', '600', 1,1);
}

function showPrivacyPolicy()
{
	centrePopup('http://www.site24x7.com/website/privacypolicy.jsp', 'new', '700', '600', 1,1);
			
}
function Get_Cookie(check_name) {
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false;
	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );


		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			
				// we need to handle case where cookie has no value but exists (no = sign, that is):
				if ( a_temp_cookie.length > 1 )
				{
					cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
				}
				// note that in cases where cookie is initialized but no value, null is returned
				return cookie_value;
				break;
			}
			a_temp_cookie = null;
			cookie_name = '';
		}
		if ( !b_cookie_found )
		{
			return null;
		}
}

function Set_Cookie(name,value,expires,path,domain,secure) {
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
	( ( path ) ? ";path=" + path : "" ) +
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );

}

function Delete_Cookie(name,path,domain) {
    if (Get_Cookie(name)) document.cookie = name + "=" +
        ( (path) ? ";path=" + path : "") +
        ( (domain) ? ";domain=" + domain : "") +
        ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function setSecureCookie(ckVal){
	if(document.getElementById('j_secureAccess').checked||ckVal==true){
		Delete_Cookie("pc","/");
		Set_Cookie("pc","https","","/");
		
	
}
	else{
		Delete_Cookie("pc","/");
		
		
		
}
	
}
function fnOnload(Val){
	if(Val){
		document.getElementById('j_secureAccess').checked=true;
	}
	else{
		document.getElementById('j_secureAccess').checked=false;
	}
	
}
function validateMobileUser(Val) {
	setSecureCookie(Val);
	if((document.mainform.j_username.value)== '')
	{
		document.getElementById("emptymsg").innerHTML="<b>EMail cannot be empty</b>";
		return false;
	}
	else if((document.mainform.j_password.value)== '')
	{
		document.getElementById("emptymsg").innerHTML="<b>Password cannot be empty</b>";
		return false;
	}
if(document.mainform.j_remember.checked)
{
	var val1 = document.mainform.userName.value;
	var val2 = Encrypt(document.mainform.passWord.value);
	SetCookie("un",val1,2000);
	SetCookie("pd",val2,2000);
}
else
{
	deleteCookie("un");
	deleteCookie("pd");	
}


}
function getName(Val)
{
	
var name = getCookie("un");
var password = getCookie("pd");

if(name != null)
{
	document.mainform.userName.value = name
}
if(password != null)
{
	document.mainform.passWord.value=Decrypt(password);
}
if(name != null && password != null)
{
	document.mainform.j_remember.checked = true;
}
fnOnload(Val);
}
function SetCookie(cookieName,cookieValue,nDays) {
var today = new Date();
var expire = new Date();
if (nDays==null || nDays==0) nDays=1;
	expire.setTime(today.getTime() + 3600000*24*nDays);
document.cookie = cookieName+"="+escape(cookieValue)
            + ";expires="+expire.toGMTString();
}
function getCookie(name) {
var dc = document.cookie; var prefix = name + "="; var begin = dc.indexOf("; " + prefix);
	if (begin == -1)
	{
	begin = dc.indexOf(prefix); if (begin != 0) return null;
}
else
{
	begin += 2;
}
var end = document.cookie.indexOf(";", begin);
if (end == -1) 
{
	end = dc.length;
	}
	return unescape(dc.substring(begin + prefix.length, end)); 
}
function deleteCookie ( cookie_name )
{
var cookie_date = new Date ( );
cookie_date.setTime ( cookie_date.getTime() - 1 );
document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}
function Encrypt(theText) {
	output = new String;
	Temp = new Array();
	Temp2 = new Array();
	TextSize = theText.length;
	for (i = 0; i < TextSize; i++) {
	rnd = Math.round(Math.random() * 122) + 68;
	Temp[i] = theText.charCodeAt(i) + rnd;
	Temp2[i] = rnd;
	}
	for (i = 0; i < TextSize; i++) {
	output += String.fromCharCode(Temp[i], Temp2[i]);
	}
	return output;
}
function Decrypt(theText) {
	output = new String;
	Temp = new Array();
	Temp2 = new Array();
	TextSize = theText.length;
	for (i = 0; i < TextSize; i++) {
	Temp[i] = theText.charCodeAt(i);
	Temp2[i] = theText.charCodeAt(i + 1);
	}
	for (i = 0; i < TextSize; i = i+2) {
	output += String.fromCharCode(Temp[i] - Temp2[i]);
	}
	return output;
}



function centrePopup(url,name,x,y,scroll,resize)

{ 
	var posX = (screen.width/2)-(x/2);
	var posY = (screen.height/2)-(y/2);
	var winPref = "width=" + x + ",height=" + y
		       + ",innerWidth=" + x + ",innerHeight=" + y
		       + ",left=" + posX + ",top=" + posY
		       + ",screenX=" + posX + ",screenY=" + posY
		       + ",toolbar=0" + ",location=0,directories=0,"
		       + ",resizable=" + resize +",width=" + x
		       + ",height=" + y + ",scrollbars=" + scroll;
		    var remoteWin = null;
		       remoteWin = window.open(url,name,winPref);
		          if (window.focus)
				     {
					        remoteWin.focus();
				     }
}

function setupLogin()
	
{
hideAllLoginDivs();
signtxt.className = "";
loginpassword.className = "";
LOGINEMAIL.className = "";
signin.className = "";
forgotpassword.className = "";
NEW_USER_ROW.className = "";
}

function hideAllLoginDivs()
{
       signtxt.className = "hide";
       LOGINEMAIL.className = "hide";
       loginpassword.className = "hide";
       signin.className = "hide";
       forgotpassword.className = "hide";
       SIGN_UP.className = "hide";
       NEW_USER_ROW.className = "hide";
       NEW_USER_EMAIL.className = "hide";
       NEW_PASSWORD.className = "hide";
       CONFIRM_PASSWORD.className="hide";
       AGREE.className = "hide";
       SUBMIT_ROW.className = "hide";	
      
      
}




function fieldvalidate()
{
	if (!emptyCheck("loginName","Email Id"))
{
		return false
}
			if (!emailValidate("loginName", "Email id"))
			{
			
return false;
}
	if (!emptyCheck("password","Password"))
        {
		
return false
         }
	
			if (getObj('password').value.length < 6 )
			{
				
alert("Password length should be minimum of 6 characters")
					return false
			}
        if (!emptyCheck("confirmpassword","Re-type Password"))
        {		
		return false;
        }    
	if ((getObj('password').value)!=(getObj('confirmpassword').value) )
                        {
                                alert('Password does not match')
                                        return false
                        }
 
	document.signUpForm.action="../login/registerUser.do";
	document.signUpForm.submit()
}


// ScrollEffect.limit = 170;
//	ScrollEffect.closelimit= 169;
//	ScrollEffect.togglelimit = 190;
//	ScrollEffect.topplelimit = 161;
	

 try
{
		document.signUpForm.browsertimezone.value=getBrowserTimeZone();
	}
	catch(e)
	{
	}
