function trim(sString) {
	if(sString) {
		while (sString.substring(0,1) == ' ')
		{
			sString = sString.substring(1, sString.length);
		}
		while (sString.substring(sString.length-1, sString.length) == ' ')
		{
			sString = sString.substring(0,sString.length-1);
		}
	}
	return sString;
}
function changeText(obj, defaultVal, type) {
	if(trim(obj.value) == '' && type == 'blur') {
		obj.value = defaultVal;
	}
	if(obj.value == defaultVal && type == 'focus') {
		obj.value = '';
	}
}
function openforgotpasswordcenter(url)
{
    window.open(url,'','resizable=no,location=no,menubar=no,scrollbars=no,toolbar=no,fullscreen=no,dependent=no,width=440,height=200,left=50,top=50,right=5,bottom=5');
}

function popupWindow(url, width, height, resizable, scrollbars , top, left) {
	if(trim(url) != '') {
		
		if(width == '') { width = 150; }
		if(height == '') { height = 150; }
		
		resizable = resizable;
		if(resizable == '') { resizable = 'yes'; }
		
		scrollbars = scrollbars;
		if(scrollbars == '') { scrollbars = 'no'; }
		
		if(top == '') { top = 50; }
		if(left == '') { left = 50; }
		window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=' + scrollbars + ',resizable=' + resizable + ',copyhistory=no,width=' + width + ',height=' + height + ',top=' + top + ',left=' + left );
	}
}

function OpenHelp(url) {		
	//url = "studio_help.php";
	//window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=930,height=625,top=50,left=50');
	
	var hreflink = '/studio_help.php';
	GB_showCenter('Studio Help', hreflink, 625, 940);
	
}

function emailValidate(email) {
	var error = '';
	var emailFilter=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
	if (email.search(emailFilter) == -1) {
	       error = "error";
	}
	return error;
}
// Start isNumber function
function isNumber(numstr, errString) {
	
	numdecs = 0;
	for (i = 0; i < numstr.length; i++) {
		mychar = numstr.charAt(i);
		if ((mychar >= "0" && mychar <= "9") || mychar == "." ) {
			if (mychar ==  ".")
				numdecs++;
		} else {
			return errString;
		}
	}
	
	if (numdecs > 1) {
		return errString;
	}
	return '';
}

// Start isNumber function
function isCurrency(numstr, errString, dec_point, thousand_sep) {
	if(dec_point == '' || (thousand_sep != '.' && thousand_sep != "" )) {
		dec_point = '.';
	}
	if(thousand_sep == '' || (dec_point != ',' && dec_point != "" )) {
		thousand_sep = ',';
	}
	numdecs = 0;
	for (i = 0; i < numstr.length; i++) {
		mychar = numstr.charAt(i);
		if ((mychar >= "0" && mychar <= "9") || mychar == dec_point || mychar == thousand_sep ) {
			if (mychar == dec_point)
				numdecs++;
		} else {
			return errString;
		}
	}
	
	if (numdecs > 1) {
		return errString;
	}
	return '';
}
// end isNumber function


// Start : Ajax Object creation Function //
function GetXmlHttpObject(handler)
{
	var objXmlHttp=null

	if (navigator.userAgent.indexOf("Opera")>=0)
	{
		alert("This Site doesn't work in Opera")
		return
	}
	if (navigator.userAgent.indexOf("MSIE")>=0)
	{
		var strName="Msxml2.XMLHTTP"
		if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
		{
			strName="Microsoft.XMLHTTP"
		}
		try
		{
			objXmlHttp=new ActiveXObject(strName)
			objXmlHttp.onreadystatechange=handler
			return objXmlHttp
		}
		catch(e)
		{
			alert("Error. Scripting for ActiveX might be disabled")
			return
		}
	}
	if (navigator.userAgent.indexOf("Mozilla")>=0)
	{
		objXmlHttp=new XMLHttpRequest()
		objXmlHttp.onload=handler
		objXmlHttp.onerror=handler
		return objXmlHttp
	}
}
// End : Ajax Object creation Function //
//admin side validation
function validationAdditionlaInfo(count)	
{
	var errorflag = false;
	if(document.getElementById("options_type").value == '') {
	
		document.getElementById("PtypeError").innerHTML = "Select Type";
		errorflag = true;
		
	} else {
		document.getElementById("PtypeError").innerHTML = "";
	}
	
	
	
	/*for(var i=0;i<count;i++){
		
		if(trim(document.getElementById('title['+i+']').value)=='')
		{
			document.getElementById("PTitleError["+i+"]").innerHTML = 'Title is required';
			errorflag = true;
		}
		else  {
			document.getElementById("PTitleError["+i+"]").innerHTML = "";
		}
		
	}*/
	
	if(trim(document.getElementById("title[" + default_tab + "]").value) == '') {
		document.getElementById("PTitleError[" + default_tab + "]").innerHTML = "Title is required";
		errorflag = true;
		
	} else {
		document.getElementById("PTitleError[" + default_tab + "]").innerHTML = "";
	}

	if(errorflag == true){
		//TabbedPanels1.showPanel(default_tab);
		return false;
	}
	else{
		return true;
	}
}
