/*
with (navigator) if (appName.indexOf('Microsoft')!=-1 && appVersion.indexOf('Mac')==-1) document.write(''+
'<scr'+'ipt language="VBScript">\nOn error resume next\n'+
'MM_dir = IsObject(CreateObject("SWCtl.SWCtl.1"))\n'+
'MM_flash = NOT IsNull(CreateObject("ShockwaveFlash.ShockwaveFlash"))\n</'+'script>');

function MM_checkPlugin(plgIn, theURL, altURL, autoGo) { //v4.0
	  var ok=false; document.MM_returnValue = false;
	  with (navigator) if (appName.indexOf('Microsoft')==-1 || (plugins && plugins.length)) {
		ok=(plugins && plugins[plgIn]);
	  } else if (appVersion.indexOf('3.1')==-1) { //not Netscape or Win3.1
		if (plgIn.indexOf("Flash")!=-1 && window.MM_flash!=null) ok=window.MM_flash;
		else if (plgIn.indexOf("Director")!=-1 && window.MM_dir!=null) ok=window.MM_dir;
		else ok=autoGo; }
	  if (!ok) theURL=altURL; if (theURL) window.location=theURL;
	}

//Synage Inside ePublication form validation
function verifyRequired() {
  var fieldName = trimspace(document.icpsignup.fields_fname.value);
  var emailID = trimspace(document.icpsignup.fields_email.value);
  if (fieldName == "" || fieldName == 'Name') {
    alert("The Name field is required.");
	document.icpsignup.fields_fname.focus();
    return false;
  }
  if (emailID == "" || emailID == 'Email') {
    alert("The Email field is required.");
	document.icpsignup.fields_email.focus();
    return false;
  }
  if (emailID != "" && emailID != 'Email') {
	 if(!checkEmail(document.icpsignup.fields_email.value)) {
		document.icpsignup.fields_email.focus();
		return false;
	}
  }
	return true;
}
//email format validation
function checkEmail(email) {

	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)){
		return (true)
	}
		alert("Invalid E-mail address! Please enter your correct email address.")
		return (false)
}

//this function use to trim the spaces in text field
function trimspace(str)
{		
	var len = str.length;
	if (len != 0){
		for (var i=0;i<len;i++) {	
			if(str.indexOf(" ")==0)
				str=str.substring(1,len);
		}
		var strtrim = str;
		return strtrim;
	} else {
		return str;
	}
}

function check_name() {
	if(document.icpsignup.fields_fname.value == 'Name')
		document.icpsignup.fields_fname.value = '';
	else if(document.icpsignup.fields_fname.value == '')
		document.icpsignup.fields_fname.value = 'Name';
	else
		document.icpsignup.fields_fname.value = document.icpsignup.fields_fname.value;
}
function check_email() {
	if(document.icpsignup.fields_email.value == 'Email')
		document.icpsignup.fields_email.value = '';
	else if(document.icpsignup.fields_email.value == '')
		document.icpsignup.fields_email.value = 'Email';
	else
		document.icpsignup.fields_email.value = document.icpsignup.fields_email.value;
}
*/



/*
function moveTo() {
  location.href = "http://www.deskaway.com/index.php";
}
window.onload=setTimeout('moveTo()', 5000);
*/

function generate_address( username, hostname ) {
        var domain = "deskaway.com";
        var atsign = "&#64;";
        var addr = username + atsign + hostname + domain;
        document.write("<" + "a" + " " + "href=" + "mail" + "to:" + addr + ">" + addr + "<\/a>");
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}



// (C) 2001 www.CodeLifter.com
// http://www.codelifter.com
// Free for all users, but leave in this header

var theURL = 'http://www.deskaway.com/newsletter-signup/index.php';
var width  = 375;
var height = 300;

function popWindow() {
newWindow = window.open(theURL,'newWindow','toolbar=no,menubar=no,resizable=no,scrollbars=no,status=no,location=no,top=200,left=200,width='+width+',height='+height);
}


/****************************************************
     Author: Eric King
     Url: http://redrival.com/eak/index.shtml
     This script is free to use as long as this info is left in
     Featured on Dynamic Drive script library (http://www.dynamicdrive.com)
****************************************************/

/*
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=-20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);}
*/

//scrolling
function _gotop() {   
    var ts=0;   
    if (document.body.scrollTop){
        ts=document.body.scrollTop;
    } else{
        ts=window.pageYOffset;       
    }
    if (ts>0){
        var nv=(ts-5)*0.2;
        if (nv<1) nv=1;
        scrollBy(0,-nv);
        setTimeout("_gotop()",15);
    }
   
}

//this function use to trim the spaces in text field
function trimspace(str){		
	var len = str.length;

	if (len != 0){
		for (var i=0;i<len;i++){	
			if(str.indexOf(" ")==0)
				str=str.substring(1,len);
		}
		var strtrim = str;
		return strtrim;
	}
	else {
		return str;
	}
}

// Function for checking form validation of affliate login form.
function checkvalidation(){
	var firstName = trimspace(document.getElementById('firstName').value);
	var lastName = trimspace(document.getElementById('lastName').value);
	var email = document.getElementById('email').value;
	var address = trimspace(document.getElementById('address').value);
	var country = trimspace(document.getElementById('country').value);
	var state = trimspace(document.getElementById('state').value);
	var city = trimspace(document.getElementById('city').value);
	var zip = document.getElementById('zip').value;
	var phone = document.getElementById('phone').value;
	var captcha = document.getElementById('captcha').value;
	
	
	// Condition for checking first name empty.
	if(firstName == ""){
		alert('Please enter your first name');

		document.getElementById('firstName').focus();
		return false;
	}

	// Condition for checking last name empty.
	if(lastName == ""){
		alert('Please enter your last name');

		document.getElementById('lastName').focus();
		return false;
	}

	// Condition for checking email.
	if(checkEmail(email) == false){
		alert('Please enter your email address');

		document.getElementById('email').focus();
		return false;
	}

	// Condition for checking address.
	if(address == ""){
		alert('Please enter your billing address');

		document.getElementById('address').focus();
		return false;
	}

	// Condition for checking country.
	if(country == ""){
		alert('Please enter your country');

		document.getElementById('country').focus();
		return false;
	}

	// Condition for checking state.
	if(state == ""){
		alert('Please enter your state');

		document.getElementById('state').focus();
		return false;
	}

	// Condition for checking city.
	if(city == ""){
		alert('Please enter your city');

		document.getElementById('city').focus();
		return false;
	}

	// Condition for checking city.
	if(captcha == ""){
		alert('Please enter the exact same numbers shown in the picture');

		document.getElementById('captcha').focus();
		return false;
	}
}

// email format validation
function checkEmail(email) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(email)){
		return true;
	}
		return false;
}

//check the paramter is int ot not
function isInteger(s)
{   var i;
	for (i = 0; i < s.length; i++)
	{   
		// Check that current character is number.
		var c = s.charAt(i);
		if (((c < "0") || (c > "9"))) return false;
	}
	// All characters are numbers.
	return true;
}

function buttonEnabled(){
	var agreement = document.getElementById('agreement').checked;
	
	if(agreement){
		document.getElementById("submit").disabled = false;
	}else{
			document.getElementById("submit").disabled = true;
	}
}

/* This function will highlight the row onMouseOver */
function onMouserOver_Change_Row_Color(row_id, row_color, from){

	//alert('==='+row_id+'<==>'+from);
	// Come form welcomes
	if(from == 'welcome') document.getElementById("welcome_tr_"+row_id).className = 'onMouseOverTableColor';
	
	// Come form affiliate index
	if(from == 'index') document.getElementById("index_tr_"+row_id).className = 'onMouseOverTableColor';
}

/* This function will turn to original the row onMouseOut */
function onMouserOut_Change_Row_Color(row_id, row_color, from){
	// Come form welcomes
	if(from == 'welcome') document.getElementById("welcome_tr_"+row_id).className = row_color;

	// Come form affiliate index
	if(from == 'index') document.getElementById("index_tr_"+row_id).className = row_color;

}

// This function open a popup for Promotional Graphcs & Logo
function viewLogo(fileName)
{
	window.open(fileName, "list", "scrollbars=yes, resizable=yes, top=20, left=100, width=800, height=600");
}

// Function for generate link.
function genLink(affliateId){
	var text = document.getElementById('generateLinkTextBox').value;

	// Condition for checking generate link box.
	if(text == ""){
		alert('Please enter text for generating link');

		document.getElementById('generateLinkTextBox').focus();
		return false;
	}else{
		document.getElementById('genratedLink').innerHTML = '<textarea name="htmlLink" id ="htmlLink" rows="1" cols="60" onclick="selectAll();"><a href="http://www.deskaway.com?da-rf='+affliateId+'" target="_blank">'+text+'</a></textarea><br><span style="font-size:11px; color:#666666;">(copy this code within your HTML page)</span>'; 
	}
}

// Function for selecting text in textarea when clicking on it.
function selectAll(){
	var textValue = document.getElementById('htmlLink').value;
	document.getElementById('htmlLink').focus();
	document.getElementById('htmlLink').select();

}

// Function for selecting text in textarea when clicking on it.
function selectBanner(bannerId){
	//var textValue = document.getElementById('banner1').value;
	document.getElementById(bannerId).focus();
	document.getElementById(bannerId).select();

}
