function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}
function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}
function Trim(TRIM_VALUE){
		if(TRIM_VALUE.length < 1){
			return"";
		}
			TRIM_VALUE = RTrim(TRIM_VALUE);
			TRIM_VALUE = LTrim(TRIM_VALUE);
		if(TRIM_VALUE==""){
			return "";
		}
		else{
			return TRIM_VALUE;
		}
} //End Function
function RTrim(VALUE){
		var w_space = String.fromCharCode(32);
		var v_length = VALUE.length;
		var strTemp = "";
		if(v_length < 0){
			return"";
	}
	var iTemp = v_length -1;

	while(iTemp > -1){
		if(VALUE.charAt(iTemp) == w_space){
	}
	else{
		strTemp = VALUE.substring(0,iTemp +1);
		break;
	}
	iTemp = iTemp-1;
} //End While
return strTemp;
} //End Function

function LTrim(VALUE){
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
		return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;

	while(iTemp < v_length){
		if(VALUE.charAt(iTemp) == w_space){
	}
	else{
		strTemp = VALUE.substring(iTemp,v_length);
	break;
	}
	iTemp = iTemp + 1;
	} //End While
	return strTemp;
} //End Function
function getKeyCode(evt)
{
  evt = (evt) ? evt : (window.event) ? event : null;
  if (evt)
  {
    var charCode = (evt.charCode) ? evt.charCode :
                   ((evt.keyCode) ? evt.keyCode :
                   ((evt.which) ? evt.which : 0));
	return charCode;
  }    
}
function isObject(a) {
    return (a && typeof a == 'object');
}
function isFunction(a) {
    return typeof a == 'function';
}

function isNull(a) {
    return typeof a == 'object' && !a;
}

function isNumber(a) {
    return typeof a == 'number' && isFinite(a);
}
function isString(a) {
    return typeof a == 'string';
}

function isUndefined(a) {
    return typeof a == 'undefined';
} 
function isAlien(a) {
   return isObject(a) && typeof a.constructor != 'function';
}

function isArray(a) {
    return isObject(a) && a.constructor == Array;
}

function isBoolean(a) {
    return typeof a == 'boolean';
}

function isEmpty(o) {
    var i, v;
    if (isObject(o)) {
        for (i in o) {
            v = o[i];
            if (isUndefined(v) && isFunction(v)) {
                return false;
            }
        }
    }
    return true;
}
function stripHTMLSimple(oldStr) {
   var newStr = "";

   var inTag = false;

   for(var i = 0; i < oldStr.length; i++) {

        if(oldStr.charAt(i) == '<') inTag = true;

        if(oldStr.charAt(i) == '>') {

              inTag = false;

              i++;

        }

        if(!inTag) newStr += oldStr.charAt(i);
   }

   return newStr;

}
function stripHTMLRegEx(oldStr)
{

	/*Remove < > using the below reg ex =======>>     /<&#91;^>&#93;*>/g        */
	var tmpStr = oldStr.replace(/(<([^>]+)>)/ig, "");
	/*Remove &nbsp 's using the below reg ex =======>>           /^&nbsp;$/ig  */
	tmpStr = tmpStr.replace(/&nbsp;/ig,"");
	
	/*Remove &amp; 's using the below reg ex =======>>           /^&amp;$/ig  */
		tmpStr = tmpStr.replace(/&amp;/ig,"&");
  return tmpStr; 
}
function validateEmailRegEx(str){
	var testresults= false;
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(str))
		testresults=true
	else{
		alert("Please input a valid email address!")
		testresults=false
	}
	return (testresults)
}
var exp = /[$\\@\\\#%\^\&\*\(\)\[\]\+\{\}\`\~\=\|]/;
function preventSpecialCharacterInput(val) {
	var strPass = val.value;
	var strLength = strPass.length;
	var lchar = val.value.charAt((strLength) - 1);
	if(lchar.search(exp) != -1) {
		var tst = val.value.substring(0, (strLength) - 1);
	val.value = tst;
   }
}
/*Place it in the KeyPress event if IE */
function preventNonNumericCharacterInput(obj,evt)
{
			if ((evt.keyCode >= 47) && (evt.keyCode <= 57) )
		    {
		       evt.returnValue = true;
			}
			else
			{
		    	evt.keyCode = 0;
  				return false;
	//		  event.returnValue = false;
			}		
}
function hasNonNumericCharacterInput(obj,evt)
{
		e= evt;
		goods ="0123456789";
		var key, keychar;
	key = (window.event) ? window.event.keyCode : ((e) ? e.which : null);
	if (key == null) return true;
 
	keychar = String.fromCharCode(key);
	keychar = keychar.toLowerCase();
	goods = goods.toLowerCase();
 
	if (goods.indexOf(keychar) != -1)
		return true;
 
	if (key==null || key==0 || key==8 || key==9 || key==13 || key==27)
		return true;
 
	return false;
}
function preventNonNumericDotValidation(obj)
{ 
			if ((event.keyCode<46) || (event.keyCode >46 && event.keyCode < 48 ) || (event.keyCode > 57)) 
			{
				event.returnValue = false;
			} 
			else
			{
				var v = obj.value; 
				for(var i=0; i<v.length; i++)
				{
					if(v.charAt(i)=='.')
					{
						if(event.keyCode == 46)
						{
							event.returnValue = false;
						}
					}
				}
				if(v.indexOf(".") >= 0)
				{
					if(v.length - v.indexOf(".")>2)
					{
						event.returnValue = false;
					}
				}
			}
			var v = obj.value;
			if(v.length >= 5)
			{
				var tt =getKeyCode(event);
				if((v.indexOf(".") == -1) && (tt != 46))
				{
					event.returnValue = false;
				}			
			}
}
function checkDomain(nname)
{
var arr = new Array(
'.com','.net','.org','.biz','.coop','.info','.museum','.name',
'.pro','.edu','.gov','.int','.mil','.ac','.ad','.ae','.af','.ag',
'.ai','.al','.am','.an','.ao','.aq','.ar','.as','.at','.au','.aw',
'.az','.ba','.bb','.bd','.be','.bf','.bg','.bh','.bi','.bj','.bm',
'.bn','.bo','.br','.bs','.bt','.bv','.bw','.by','.bz','.ca','.cc',
'.cd','.cf','.cg','.ch','.ci','.ck','.cl','.cm','.cn','.co','.cr',
'.cu','.cv','.cx','.cy','.cz','.de','.dj','.dk','.dm','.do','.dz',
'.ec','.ee','.eg','.eh','.er','.es','.et','.fi','.fj','.fk','.fm',
'.fo','.fr','.ga','.gd','.ge','.gf','.gg','.gh','.gi','.gl','.gm',
'.gn','.gp','.gq','.gr','.gs','.gt','.gu','.gv','.gy','.hk','.hm',
'.hn','.hr','.ht','.hu','.id','.ie','.il','.im','.in','.io','.iq',
'.ir','.is','.it','.je','.jm','.jo','.jp','.ke','.kg','.kh','.ki',
'.km','.kn','.kp','.kr','.kw','.ky','.kz','.la','.lb','.lc','.li',
'.lk','.lr','.ls','.lt','.lu','.lv','.ly','.ma','.mc','.md','.mg',
'.mh','.mk','.ml','.mm','.mn','.mo','.mp','.mq','.mr','.ms','.mt',
'.mu','.mv','.mw','.mx','.my','.mz','.na','.nc','.ne','.nf','.ng',
'.ni','.nl','.no','.np','.nr','.nu','.nz','.om','.pa','.pe','.pf',
'.pg','.ph','.pk','.pl','.pm','.pn','.pr','.ps','.pt','.pw','.py',
'.qa','.re','.ro','.rw','.ru','.sa','.sb','.sc','.sd','.se','.sg',
'.sh','.si','.sj','.sk','.sl','.sm','.sn','.so','.sr','.st','.sv',
'.sy','.sz','.tc','.td','.tf','.tg','.th','.tj','.tk','.tm','.tn',
'.to','.tp','.tr','.tt','.tv','.tw','.tz','.ua','.ug','.uk','.um',
'.us','.uy','.uz','.va','.vc','.ve','.vg','.vi','.vn','.vu','.ws',
'.wf','.ye','.yt','.yu','.za','.zm','.zw');

var mai = nname;
var val = true;

var dot = mai.lastIndexOf(".");
var dname = mai.substring(0,dot);
var ext = mai.substring(dot,mai.length);
//alert(ext);
	
if(dot>2 && dot<57)
{
	for(var i=0; i<arr.length; i++)
	{
	  if(ext == arr[i])
	  {
	 	val = true;
		break;
	  }	
	  else
	  {
	 	val = false;
	  }
	}
	if(val == false)
	{
	  	 alert("Your domain extension "+ext+" is not correct");
		 return false;
	}
	else
	{
		for(var j=0; j<dname.length; j++)
		{
		  var dh = dname.charAt(j);
		  var hh = dh.charCodeAt(0);
		  if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123) || hh==45 || hh==46)
		  {
			 if((j==0 || j==dname.length-1) && hh == 45)	
		  	 {
		 	  	 alert("Domain name should not begin are end with '-'");
			      return false;
		 	 }
		  }
		else	{
		  	 alert("Your domain name should not have special characters");
			 return false;
		  }
		}
	}
}
else
{
 alert("Your Domain name is too short/long");
 return false;
}	
return true;
}
     //Register All the Buttons with an Event to Identify the Click event for required buttons
function startProcessingCursor()
{
	if(navigator.appName == "Microsoft Internet Explorer")
	{
		fnStartProcessing(2);
	}
	else
	{
		fnStartProcessing(1);
	}
	document.body.style.cursor = 'wait'
}
function stopProcessingCursor()
{	
	if(navigator.appName == "Microsoft Internet Explorer")
	{
	fnStopProcessing(2);
	}
	else
	{
	fnStopProcessing(1);
	}
	document.body.style.cursor = 'default';
}

function fnStartProcessing(mode)
{
	if(mode == 1)
	{
		fnOnProcessing();
	}
	else
	{
		fnStartProcessingEnableDisableComponents();
	}	
}
function fnStopProcessing(mode)
{
	if(mode == 1)
	{
		fnAfterProcessing();		
	}
	else
	{
		fnStopProcessingEnableDisableComponents();
	}
}

//This Function is used to set the Flag that required Buttons where Click
function OnClicked()
{
   properEvent=true;
}

// do not edit below this line
// ===========================
	bV  = parseInt(navigator.appVersion)
	bNS = navigator.appName=="Netscape"
	bIE = navigator.appName=="Microsoft Internet Explorer"

function nrc(e) {
   if (bNS && e.which == 1){
      return false
   } else if (bIE && (event.button == 1)) {
     return false;
   }
}
function fnOnProcessing()
{
	document.onmousedown = nrc;
	document.onmouseup = nrc;
	document.onclick = nrc;
	
	if (document.layers) 
	{
		window.captureEvents(Event.MOUSEDOWN);
		window.captureEvents(Event.MOUSEUP);
		window.captureEvents(Event.CLICK);
	}	
//	window.document.releaseEvents();
	
	if (bNS && bV<5) window.onmousedown = nrc;
	if (bNS && bV<5) window.onmouseup = nrc;
	if (bNS && bV<5) window.onclick = nrc;	
	
//	window.document.releaseEvents(Event.MOUSEDOWN);
	//window.document.releaseEvents(Event.MOUSEUP);
//	window.document.releaseEvents(Event.CLICK);
	//window.document.detachEvent();
//	window.document.attachEvent()
}
function fnAfterProcessing()
{
	document.onmousedown = "";
	document.onmouseup = "";
	document.onclick = "";		
}
function fnStartProcessingEnableDisableComponents()
{
	registerEventHandler();
	disableAllInputControls();
	//disableAllHyperLinkControls();
}
function fnStopProcessingEnableDisableComponents()
{
//	registerEventHandler();
	enableAllInputControls();
	//enableAllHyperLinkControls();
}
function enableAllInputControls()
{
  //Disables all the INPUT Controls
            for(i=0;i<document.all.tags('INPUT').length;i++)
            {         
                 var io = document.all.tags('INPUT')[i];     
                
                 //Make sure you are not working with hidden INPUTS
                 if(io.type != 'hidden')
                 {
                      io.disabled=false;
                      io.style.cursor ="default";
                 }
                  io.onmousedown = "";
           }
          for(i=0;i<document.all.tags('SELECT').length;i++)
          {         
                 var select = document.all.tags('SELECT')[i];       

                 //Make sure you are not working with hidden INPUTS
                 if(select.type != 'hidden')
                 {
                      select.disabled=false;
                      select.style.cursor ="default";
                 }
                  select.onmousedown = "";
           }
}
function enableAllHyperLinkControls()
{
            //Disables all the HyperLink Controls
            for(i=0;i<document.all.tags('a').length;i++)
            {         
                 var io = document.all.tags('a')[i];
                 //Make sure you are not working with hidden Links

                 if(io.type != 'hidden')
                 {
                       io.disabled=false;
                       io.style.cursor ="default";
                 }

              }
             //divResult.style.display = "none";
             //divWait.style.display="block";
              properEvent=true;
}

function registerEventHandler()
{
     for(i=0;i<document.all.tags('INPUT').length;i++)
     {         
         var io = document.all.tags('INPUT')[i];     
         io.attachEvent("onclick",OnClicked);
     }
}
function disableAllInputControls()
{
  //Disables all the INPUT Controls
            for(i=0;i<document.all.tags('INPUT').length;i++)
            {         
                 var io = document.all.tags('INPUT')[i];     
                 //Make sure you are not working with hidden INPUTS
                 
                 if(io.type != 'hidden')
                 {
                      io.disabled=true;
                      io.style.cursor ="wait";
                 }
                 io.onmousedown = nrc;
           }
          for(i=0;i<document.all.tags('SELECT').length;i++)
          {         
                 var select = document.all.tags('SELECT')[i];       

                 //Make sure you are not working with hidden INPUTS
                 if(select.type != 'hidden')
                 {
                      select.disabled=true;
                      select.style.cursor ="wait";
                 }
                                  select.onmousedown = nrc;
          }
}
function disableAllHyperLinkControls()
{
            //Disables all the HyperLink Controls
            for(i=0;i<document.all.tags('a').length;i++)
            {         
                 var io = document.all.tags('a')[i];
                 //Make sure you are not working with hidden Links

                 if(io.type != 'hidden')
                 {
                       io.disabled=true;
                       io.style.cursor ="wait";
                 }
              }
             //divResult.style.display = "none";
             //divWait.style.display="block";
              properEvent=false;
}
