
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//////////// AJAX - START //////////////////
var isDOM = (document.getElementById ? true : false);
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);
var isDyn = (isDOM || isIE4 || isNS4);

var xmlHttp; 
function GetXmlHttpObject()
{
	xmlHttp=null;
  	try
    {
    	// Firefox, Opera 8.0+, Safari
    	xmlHttp=new XMLHttpRequest();
    }
  	catch (e)
    {
    	// Internet Explorer
    	try
      	{
      		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      	}
    	catch (e)
      	{
      		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      	}
    }
  	return xmlHttp;
}
function stateChanged(placeholder) 
{ 
	if(xmlHttp.readyState==4 && placeholder!="")
	{ 
	    
		switch(document.getElementById(placeholder).nodeName)
		{
			case "input" || "INPUT": 
				document.getElementById(placeholder).value=xmlHttp.responseText;
				break;
			case "textarea" || "TEXTAREA": 
				document.getElementById(placeholder).value=xmlHttp.responseText;
				break;
			case "select" || "SELECT": 
				document.getElementById(placeholder).value=xmlHttp.responseText;
				break;
			default : 
				var objDiv = getRef(placeholder);
				//alert(xmlHttp.responseText.length);
				objDiv.innerHTML=xmlHttp.responseText;
				objDiv.scrollTop = objDiv.scrollHeight;
				break;
		}
	}
}
function getRef(id)
{
 	if (isDOM) return document.getElementById(id);
 	if (isIE4) return document.all[id];
 	if (isNS4) return document.layers[id];
}
function getFieldRef(id)
{
	if(document.getElementById[id]!=null)return document.getElementById[id];
	if(document.all[id]!=null)return document.all[id];
}
function ajaxfnc(objectid,pagename,fnc,extra_val,placeholder)
{	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
  	{
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	var url=pagename;
	url=url + "?prth_act_" + objectid + "=callajax";
	url=url + "&prth_obj_id_" + objectid + "=" + objectid;
	url=url+"&fnc="+fnc;	
	if(extra_val!="")url=url + FetchFieldValueList(extra_val);	
	xmlHttp.onreadystatechange = function ()
	{
		if (xmlHttp.readyState == 4) stateChanged(placeholder);
	}
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);	
}
function FetchFieldValueList(FieldList)
{
	var rtnStr="";
	var FieldList_Array=FieldList.split(",");
	var field_num=0;
	for(field_num=0;field_num < FieldList_Array.length;field_num++)
	{
		var objFld=getFieldRef(FieldList_Array[field_num]);		
		rtnStr = rtnStr + "&" + FieldList_Array[field_num] + "=" + objFld.value;
	}
	return rtnStr;
}
function ajaxAutoCall(objectid,pagename,fnc,extra_val,placeholder,milliseconds)
{
	ajaxfnc(objectid,pagename,fnc,extra_val,placeholder);
	setTimeout("ajaxAutoCall('" + objectid + "','" + pagename + "','" + fnc + "','" + extra_val + "','" + placeholder + "','" + milliseconds + "')", milliseconds);
	//setTimeout("ajaxAutoCall('" + objectid + "','" + pagename + "','" + fnc + "','" + extra_val + "','" + placeholder + "','" + milliseconds + "')", 30000);
}

//////////// AJAX - END //////////////////
function prth_system_fnc_nevigation(objid,frmname,act,orderby,cpage,systemextra)
{
  	var objfrm=eval("document." + frmname);
	
	objfrm.elements["prth_act_"+objid].value=act;
 
	objfrm.elements["prth_orderby_"+objid].value=orderby;
	
	objfrm.elements["prth_cpage_"+objid].value=cpage;
	
	if(systemextra)
		objfrm.elements["prth_system_extra_"+objid].value=systemextra;
	
	objfrm.submit();
}
var marked_row = new Array;
theDefaultStyleClass="gridrows";
thePointerStyleClass="gridrows_mouseover"; //mouseover
theMarkStyleClass="gridrows_mousedown"; //marking a row
function setPointer(theRow, theRowNum, theAction)
{
//    var theCells = null;

//    // 1. Pointer and mark feature are disabled or the browser can't get the
//    //    row -> exits
//    if ((thePointerStyleClass == '' && theMarkStyleClass == '')
//        || typeof(theRow.style) == 'undefined') {
//        return false;
//    }

//    // 2. Gets the current row and exits if the browser can't get it
//    if (typeof(document.getElementsByTagName) != 'undefined') {
//        theCells = theRow.getElementsByTagName('td');
//    }
//    else if (typeof(theRow.cells) != 'undefined') {
//        theCells = theRow.cells;
//    }
//    else {
//        return false;
//    }

//    // 3. Gets the current color...
//    var rowCellsCnt  = theCells.length;
//    var domDetect    = null;
//    var currentColor = null;
//    var newColor     = null;
//    // 3.1 ... with DOM compatible browsers except Opera that does not return
//    //         valid values with "getAttribute"
//    if (typeof(window.opera) == 'undefined'
//        && typeof(theCells[0].getAttribute) != 'undefined') {
//        //currentColor = theCells[0].getAttribute('bgcolor');
//		currentColor = theCells[0].className;
//        domDetect    = true;
//    }
//    // 3.2 ... with other browsers
//    else {
//        currentColor = theCells[0].className;
//        domDetect    = false;
//    } // end 3

//    // 3.3 ... Opera changes colors set via HTML to rgb(r,g,b) format so fix it
//    if (currentColor.indexOf("rgb") >= 0) 
//    {
//        var rgbStr = currentColor.slice(currentColor.indexOf('(') + 1,
//                                     currentColor.indexOf(')'));
//        var rgbValues = rgbStr.split(",");
//        currentColor = "#";
//        var hexChars = "0123456789ABCDEF";
//        for (var i = 0; i < 3; i++)
//        {
//            var v = rgbValues[i].valueOf();
//            currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16);
//        }
//    }

//    // 4. Defines the new color
//    // 4.1 Current color is the default one
//    if (currentColor == ''
//        || currentColor.toLowerCase() == theDefaultStyleClass.toLowerCase()) {
//        if (theAction == 'over' && thePointerStyleClass != '') {
//            newColor              = thePointerStyleClass;
//        }
//        else if (theAction == 'click' && theMarkStyleClass != '') {
//            newColor              = theMarkStyleClass;
//            marked_row[theRowNum] = true;
//        }
//    }
//    // 4.1.2 Current color is the pointer one
//    else if (currentColor.toLowerCase() == thePointerStyleClass.toLowerCase()
//             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
//        if (theAction == 'out') {
//            newColor              = theDefaultStyleClass;
//        }
//        else if (theAction == 'click' && theMarkStyleClass != '') {
//            newColor              = theMarkStyleClass;
//            marked_row[theRowNum] = true;
//        }
//    }
//    // 4.1.3 Current color is the marker one
//    else if (currentColor.toLowerCase() == theMarkStyleClass.toLowerCase()) {
//        if (theAction == 'click') {
//            newColor              = (thePointerStyleClass != '')
//                                  ? thePointerStyleClass
//                                  : theDefaultStyleClass;
//            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
//                                  ? true
//                                  : null;
//        }
//    } // end 4

//    // 5. Sets the new color...
//    if (newColor) {
//        var c = null;
//        // 5.1 ... with DOM compatible browsers except Opera
//        if (domDetect) {
//            for (c = 0; c < rowCellsCnt; c++) {
//                //theCells[c].setAttribute('bgcolor', newColor, 0);
//				theCells[c].className=newColor;
//            } // end for
//        }
//        // 5.2 ... with other browsers
//        else {
//            for (c = 0; c < rowCellsCnt; c++) {
//                //theCells[c].style.backgroundColor = newColor;
//				theCells[c].className=newColor;
//            }
//        }
//    } // end 5

//    return true;
} 
function delete_confirm(msg)
{
	delmsg="this record";
	if(msg)
		if(msg!="")	delmsg=msg;
	
	if(confirm("Are you sure you want to delete "+delmsg+" ?"))
	{
		return true;
	}
	return false;
}
function frmsubmit_loginform(objFrm)
{
	if(!NotBlank(objFrm.user_name,"User Name"))return false;
	if(!NotBlank(objFrm.password,"Password"))return false;
	return true;
}
//Blank field validation
function NotBlank(obj,cap)
{
	
	if(obj.value=="")
	{
		alert(cap + " is mandatory");
		obj.focus();
		return false;
	}
	return true;
}

function IsNumeric(obj,cap)
{
	var tempstr;
	tempstr = obj.value;
	var nreg= /[^0-9]/g;
	nresult = tempstr.match(nreg);
	if(nresult != null || obj.value=="")
	{
		alert("Please Enter Valid " + cap);
		obj.focus();
		return false;
	}
	return true;
}

function IsDecimal(obj,cap)
{
	if(isNaN(obj.value) || obj.value=="")
	{
		alert("Please Enter Valid " + cap);
		obj.focus();
		return false;
	}
	return true;
}

function blank(obj)
{
	if(obj.value=="")
	{
		alert("All fields are mandatory");
		obj.focus();
		return false;
	}
	return true;
}
function IsInteger(obj,cap)
{
	var tempstr;
	tempstr = obj.value;
	var nreg= /[^0-9]/g;
	nresult = tempstr.match(nreg);
	if(nresult != null)
	{
		alert("Please Enter Valid " + cap);
		obj.focus();
		return false;
	}
	return true;
}
function check_blankval(obj)
{
	if(obj.value=="")
	{
		alert("All fields are mandatory");
		obj.focus();
		return false;
	}
	return true;
}
//Compare Two values which is greater
function comparetwovalues(obj1,obj2)
{
	if(parseInt(obj1.value)>parseInt(obj2.value))
	{
		alert("Between textbox value is not greater To textbox value");
		obj2.focus();
		return false;
	}
	return true;
}
//Number and decimal only enter
function checknum_decimal(obj)
{
	key=window.event.keyCode;
	if((key < 48 || key > 57) && key!=46)
	{
		alert("Enter only Number and Decimal Point");
		return false;
		obj.focus();
	}		
}
function check_radioval(obj1,obj2)
{
	if(!obj1.checked && !obj2.checked)
	{
		alert("Fields with * are mandatory");
		obj1.focus();
		return false;
	}
	return true;
}
function check_checkboxval(obj,cap)
{
	if(!obj.checked)
	{
		alert("You must be agree with Terms and Conditions");
		obj.focus();
		return false;
	}
	return true;
}
function check_emailval(obj,cap)
{
	var em=obj.value;
	if(obj.value=="")
	{
		alert(cap+" is mandatory");
		obj.focus();
		return false;
	}
	atspos=em.indexOf('@') + 1;
	dtspos=em.lastIndexOf('.');
	len=em.length-3;
	if(atspos < 2 || dtspos < 3  ||dtspos <= atspos || len<dtspos)
	{
		alert("Enter Valid E-mail Address");
		obj.focus();
		return false;
	}
	return true;
}
function check_blankcountry(obj)
{
	if(obj.value==0)
	{
		alert("Fields with * color are mandatory");
		obj.focus();
		return false;
	}
	return true;
}
function check_country(obj,cobj,eobj)
{
	if(obj.value=="United States")
	{
		eobj.value="";
		if(cobj.value==0)
		{
			alert("please Select State from List Box(just for USA)");
		}
		else
		{
			cobj.value;
			return true;
		}
		cobj.focus();
		return false;
	}
	else
	{
		cobj.value=0;
		if(eobj.value=="")
		{
			alert("Please enter State in text(other) box");
		}
		else
		{
			eobj.value;
			return true;
		}	
		eobj.focus();
		return false;
	}	
}
function check_confirm_password(mobj,cobj)
{
	if(mobj.value!=cobj.value)
	{
		alert("Your Password does not match with the Confirm Password")
		mobj.value="";
		cobj.value="";
		mobj.focus();
		return false;
	}
	return true;
}
function check_length(obj,leng)
{
    var objlen=obj.value.length
	if( objlen < leng )
	{
		alert("Length must be less than limited characters");
		obj.focus();
		return false;
	}
	return true;
}
//Used for checking valid amount >0
function validamount_nozero(obj,msg)
{
	if(obj.value == "" || isNaN(obj.value))
	{
		alert("Please enter valid "+msg)
		obj.value="0.00"
		obj.focus()
		return false;
	}
	else if(obj.value <=0)
	{
	 	alert("Please enter amount greater then 0")
		obj.value="0.00"
		obj.focus()
		return false;
	}
		return true;
}   

function inline_save(frmobj)
{
		
		frmsubmit_inline(frmobj);
		//if(!frmsubmit(frmobj));
		//else frmobj.submit();
		
}
function inline_delete(objid)
{
	if(confirm("Are you sure you want to delete clicked member?"))
	{
		location.replace("?prth_act=d&prth_inline_rowid=" + objid);
		return true;
	}
	return false;
}
function sendselected(actflag,selval)
{
	location.replace("?prth_act=" + actflag + "&prth_rowid=" + selval);
}
function OpenToEdit(objid,objfrm,selval,act_val)
{
	objfrm.elements["prth_act_"+objid].value=act_val;
	objfrm.elements["prth_system_extra_"+objid].value=selval;
	objfrm.submit();
}
function FetchOnChange(objid,objfrm,fldname,act_val)
{
	objfrm.elements["prth_act_"+objid].value=act_val;	
	objfrm.submit();
}
function search(objid,objfrm,fldname,selval)
{	
	
	if(selval=="birth_date" || selval=="ht_feet" || selval=="weight" || selval=="position" || selval=="newsletter" || selval=="morefields")
	{
		objfrm.elements["prth_act_"+objid].value="change_search_interface";
		objfrm.submit();
	}
}
function open_dialogbox(path,width,height,resize,scroll,status,samewindow)
{	
	var w = 480, h = 340;
	
	if(!width)
		width="700";
	if(!height)
		height="500";
	if(!resize)
		resize="yes";
	if(!scroll)
		scroll="no";
	if(!samewindow)
		samewindow="objwnd";
	if(!status)
		status="no";
	
		
	if (document.all || document.layers)
	{
		w = screen.availWidth;
		h = screen.availHeight;
	}
	var topPos = (h-height)/2, leftPos = (w-width)/2;
	objwnd=window.open(path,samewindow,"munubar=no,titlebar=no,status="+status+",resizable="+resize+",scrollbars="+scroll+",width="+(width)+",height="+(height)+",left="+ leftPos +",top="+ topPos +",screenX="+ leftPos +",screenY="+ topPos);	
	objwnd.focus();
}

function DeleteRecord(objid,frmname,act,orderby,cpage,editid)
{
    if(delete_confirm())
	{
	    prth_system_fnc_nevigation(objid,frmname,act,orderby,cpage,editid);
	}
}
function DeleteMyRecord(objid,frmname,act,orderby,cpage,editid)
{
    if(delete_confirm())
	{
	    prth_system_fnc_nevigation('0','frmprth_0',act,orderby,cpage,editid);
	}
}

function ValidateBatch(objFrm)
{
    if(!IsNumeric(objFrm.fspid,"student_packages"))return false;
	
	if(!NotBlank(objFrm.batch_name,"Batch Name"))return false;

	if(!NotBlank(objFrm.start_date,"Start Date"))return false;

	if(!NotBlank(objFrm.end_date,"End Date"))return false;

	var i=0;
	var sts = false;
	for(i=0; i<=6; i++)
	{
	    if(objFrm.week_days[i].checked) { sts = true; break; }
	}
	if(!sts)    {alert('Please select week days.'); return false;}
		
	if(objFrm.start_h.value > objFrm.end_h.value)
	{
	    alert('Start time must be less than end time.')
	    return false;
	}
    objFrm.submit();
}

function ValidateSession(objFrm)
{
    if(!IsNumeric(objFrm.batchid,"Batch Name"))return false;
    
    if(!NotBlank(objFrm.date,"Date"))return false;
	
  	if(!IsNumeric(objFrm.session_no,"Session No"))return false;
	
	if(!IsNumeric(objFrm.coachid,"Coach Name"))return false;
	
	if(objFrm.start_h.value > objFrm.end_h.value)
	{
	    alert('Start time must be less than end time.')
	    return false;
	}
	objFrm.submit();
}

function ValidateCoachSession(objFrm)
{
    if(!IsNumeric(objFrm.batchid,"Batch Name"))return false;
    
    if(!NotBlank(objFrm.date,"Date"))return false;
	
  	if(!IsNumeric(objFrm.session_no,"Session No"))return false;
	
	if(objFrm.start_h.value > objFrm.end_h.value)
	{
	    alert('Start time must be less than end time.')
	    return false;
	}
	objFrm.submit();
}

function htmleditor(objFrm)
  {
  		if(!NotBlank(objFrm.pageid,"Page"))return false;
  		objFrm.prth_act_0.value='savepagecontent';
	    return true;
  }
  
function ValidateBooking(objFrm)
{
    if(!IsNumeric(objFrm.chuserid,"Coach"))return false;
    
    if(!IsNumeric(objFrm.packageid,"Package"))return false;
    
    if(!IsNumeric(objFrm.rinkid,"Rink"))return false;
    
    if(!IsNumeric(objFrm.session_typeid,"Session Type"))return false;
    
    if(!IsNumeric(objFrm.durationid,"Duration"))return false;
    
    if(!NotBlank(objFrm.booking_date,"Booking Date"))return false;
    
    if(!IsNumeric(objFrm.timelistid,"Time"))return false;
    
    if(!IsNumeric(objFrm.statusid,"Status"))return false;
    
    objFrm.prth_act.value='finalize';
    
    objFrm.submit();
}  

function send_email(objFrm)
  {
	
    if(!check_emailval(objFrm.email_from,"Email From")) return false;

	if(!NotBlank(objFrm.subject,"Subject")) return false;
	
	if(objFrm.bcc.value!="")
	     if(!check_emailval(objFrm.bcc,"BCC")) return false;
	
	objFrm.prth_act_0.value='send_email';
	
return true;
  }
  function test_email(objFrm)
  {
	
     if(!check_emailval(objFrm.email_from,"Email From"))return false;

	if(!NotBlank(objFrm.subject,"Subject"))return false;
	
    if(!check_emailval(objFrm.testing_email,"Test Email"))return false;

	objFrm.prth_act_0.value='test_email';
	
return true;
  }

function seteditorproperty(edt)
{
	edt.width="100%";
	edt.cmdAssetManager="modalDialogShow('../assetmanager/assetmanager.asp',640,500)";
	edt.btnFlash=true;
}

function changestatus(bookingid,statusid)
{
    document.frmprth_0.prth_act_0.value="changestatus";
    document.frmprth_0.bookingid.value=bookingid;
    document.frmprth_0.newstatusid.value=statusid;
    document.frmprth_0.submit();
}
function quickreserve(timelistid,rinkid,booking_date)
{
    document.frmprth_0.prth_act_0.value="quickreserve";
    document.frmprth_0.rinkid.value=rinkid;
    document.frmprth_0.timelistid.value=timelistid;
    document.frmprth_0.booking_date.value=booking_date;
    document.frmprth_0.submit();
}
function unreserve(bookingid,reserveid,booking_date)
{
    document.frmprth_0.prth_act_0.value="unreserve";
    document.frmprth_0.bookingid.value=bookingid;
    document.frmprth_0.reserveid.value=reserveid;
    document.frmprth_0.booking_date.value=booking_date;
    document.frmprth_0.submit();
}

function setbooking(bookingid,timelistid,rinkid,booking_date)
{
    document.frmprth_0.prth_act_0.value="quickreserve";
    if(document.frmprth_0.coach)
    {
        if(document.frmprth_0.coach.value != "")
             document.frmprth_0.chuserid.value=document.frmprth_0.coach.value;
    }
    document.frmprth_0.rinkid.value=rinkid;
    document.frmprth_0.timelistid.value=timelistid;
    document.frmprth_0.booking_date.value=booking_date;
    document.frmprth_0.bookingid.value=bookingid;
    document.frmprth_0.prth_act_0.value='setschedule';
    document.frmprth_0.submit();
}
function setplayerbooking(timelistid,rinkid,booking_date)
{
     document.frmprth_0.rinkid.value=rinkid;
     document.frmprth_0.timelistid.value=timelistid;
     document.frmprth_0.booking_date.value=booking_date;
     document.frmprth_0.prth_act_0.value='setplayerschedule';
     document.frmprth_0.submit();
}
function printschedule()
{
    var coachid=0;
    if(document.frmprth_0.coachid)
    {
        if(document.frmprth_0.coachid.value!="")
        {
            coachid=document.frmprth_0.coachid.value;
        }
    }  
    var rinkid=0;
    if(document.frmprth_0.rinkid)
    {
        if(document.frmprth_0.rinkid.value!="")
        {
            rinkid=document.frmprth_0.rinkid.value;
        }
    }   
    
     var PrintPath = "print_schedule.aspx?coachid=" + coachid + "&rinkid=" + rinkid + "&date=" + document.frmprth_0.date.value;
    open_dialogbox(PrintPath,'770','510','yes','yes')
}
function check_customerfield(objFrm)
  {
	
  		if(!IsNumeric(objFrm.programid,"Program"))return false;
	
  		if(!NotBlank(objFrm.first_name,"First Name"))return false;
	
  		if(!NotBlank(objFrm.last_name,"Last Name"))return false;
	
  		if(!NotBlank(objFrm.address,"Address"))return false;
	
  		if(!NotBlank(objFrm.city,"City"))return false;
	
  		if(!check_emailval(objFrm.email_address,"Email Address"))return false;
	
  		if(!NotBlank(objFrm.birth_date,"Birth Date"))return false;
	
  		if(!IsNumeric(objFrm.ht_feet,"Height"))return false;
	
  		if(!IsNumeric(objFrm.weight,"Weight"))return false;
  		
  		if(!IsNumeric(objFrm.ht_inches,"Inches"))return false;
	
  		if(!IsNumeric(objFrm.position,"Position"))return false;
	
	//objFrm.submit();
return true;
  }
  
  function SetAction(objid,frmname,act,userid)
  {
    var objFrm=eval("document."+frmname);
    objFrm.elements["prth_act_"+objid].value=act;
    objFrm.elements["prth_system_extra_"+objid].value=userid;
    objFrm.submit();
  }

function valid_urlname(obj)
{
	if(obj.value=="")
	{
	    alert("Franchise URL (directory name) is mandatory");
	    obj.focus();	
		return false;
	}
	var tempstr;
	tempstr = obj.value;
	var reg = /[^A-Za-z0-9_-]/g;
	result = tempstr.match(reg);
	if(result != null)
	{
		alert("Please enter valid Franchise URL (directory name). Only alpha-numeric, _, -, characters are allowed.");
		obj.focus();	
		return false;
	}
	else
		return true;
}

function checkall_click(frm,mainchkboxname,chkboxname)
{
    //alert(frm.elements[chkboxname])
	if(frm.elements[chkboxname])
	{	
		if(frm.elements[chkboxname].length)
		{
			for(i=0;i<frm.elements[chkboxname].length;i++)
			{
				frm.elements[chkboxname][i].checked=frm.elements[mainchkboxname].checked;
			}
		}
		else
		{
			frm.elements[chkboxname].checked=frm.elements[mainchkboxname].checked;
		}
	}
}

function CheckFieldList(objfrm)
{
    var i=0;
    var sts = false;
    for(i=0;i<objfrm.field_list.length;i++)
    {
        if(objfrm.field_list[i].checked)
        {
            sts = true;
        }
    }
    if(!sts)
    {
        alert('Please select at least one field.');
        return false;
    }
    return true;
}
function change_calendar_type(frmobj,tabid)
{
    if(frmobj.calendar_type.value=='monthly')
    {
        frmobj.action='index.aspx?tabid='+tabid;
        frmobj.prth_act_0.value='comingfromlistview';
        frmobj.submit();
    }
    else
    {
        frmobj.action='calendar_listview.aspx?tabid='+tabid;
        frmobj.prth_act_0.value='comingfrommonthly';
        frmobj.submit();
    }
}
function print_event_listview()
{
    //prth_filter_periodic, prth_filter_fromdate, prth_filter_todate
    //calendar_category
    var i=0;
    period="";
    objfrm = document.frmprth_0;
    for(i=0;i<objfrm.prth_filter_periodic.length;i++)
    {
        if(objfrm.prth_filter_periodic[i].checked)
        {
           period=objfrm.prth_filter_periodic[i].value;
        }
    }
    fromdate="";
    todate="";
    if(objfrm.prth_filter_fromdate)
      fromdate =  objfrm.prth_filter_fromdate.value;
      
    if(objfrm.prth_filter_todate)
      todate =  objfrm.prth_filter_todate.value;
    
    open_dialogbox('calendar_listview_print.aspx?prth_filter_periodic='+ period + '&prth_filter_fromdate='+ fromdate +'&prth_filter_todate='+ todate +'&calendar_category='+ objfrm.calendar_category.value +'&prth_obj_id_0=0&prth_act_0=save&prth_orderby_0='+objfrm.prth_orderby_0.value,760,550,'yes','yes');
}

function SetArchiveInfo()
{
    //'month,year
    slist=document.frmprth_0.archiveslist.value;
    month = slist.split("_")[0];
    year = slist.split("_")[1];
    
    document.frmprth_0.archive_month.value = month;
    document.frmprth_0.archive_year.value = year;
    document.frmprth_0.prth_act_pict.value = 'archive';
    document.frmprth_0.submit();
}
//---------------------------video Start-------------------------------
function SetArchiveInfoVideo()
{
    //'month,year
    slist=document.frmprth_video.archiveslist.value;
    month = slist.split("_")[0];
    year = slist.split("_")[1];
    
    document.frmprth_video.archive_month_video.value = month;
    document.frmprth_video.archive_year_video.value = year;
    document.frmprth_video.prth_act_video.value = 'archive';
    document.frmprth_video.submit();
}
function SetCategoryvideo()
{
    document.frmprth_video.categoryid.value = document.frmprth_video.categorylist.value;
    document.frmprth_video.prth_act_video.value = 'category';
    document.frmprth_video.submit();
}
function SetNavigationVideo(act)
{
    cpage=document.frmprth_video.prth_cpage_video.value;
    if(act=="next")
        document.frmprth_video.prth_cpage_video.value=parseInt(cpage)+1;
    else
        document.frmprth_video.prth_cpage_video.value=parseInt(cpage)-1;
    document.frmprth_video.submit();
}
//---------------------------video End-------------------------------

//---------------------------audio Start-------------------------------
function SetArchiveInfoAudio()
{
    //'month,year
    slist=document.frmprth_audio.archiveslist.value;
    month = slist.split("_")[0];
    year = slist.split("_")[1];
    
    document.frmprth_audio.archive_month_audio.value = month;
    document.frmprth_audio.archive_year_audio.value = year;
    document.frmprth_audio.prth_act_audio.value = 'archive';
    document.frmprth_audio.submit();
}
function SetCategoryAudio()
{
    document.frmprth_audio.categoryid.value = document.frmprth_audio.categorylist.value;
    document.frmprth_audio.prth_act_audio.value = 'category';
    document.frmprth_audio.submit();
}
function SetNavigationAudio(act)
{
    cpage=document.frmprth_audio.prth_cpage_audio.value;
    if(act=="next")
        document.frmprth_audio.prth_cpage_audio.value=parseInt(cpage)+1;
    else
        document.frmprth_audio.prth_cpage_audio.value=parseInt(cpage)-1;
    document.frmprth_audio.submit();
}
//---------------------------audio End-------------------------------

//CategoryID
function SetCategory()
{
    document.frmprth_0.category_id.value = document.frmprth_0.categorylist.value;
    document.frmprth_0.prth_act_pict.value = 'category';
    document.frmprth_0.submit();
}

function PhotoUploadValidation()
{
    if(!CheckAtleastOne()) return false;
    if(!fill_title(document.frmprth_0.elements["photo_1"],"Photo 1")) return false;
    if(!fill_title(document.frmprth_0.elements["photo_2"],"Photo 2")) return false;
    if(!fill_title(document.frmprth_0.elements["photo_3"],"Photo 3")) return false;
    if(!fill_title(document.frmprth_0.elements["photo_4"],"Photo 4")) return false;
    return true;
}
function CheckAtleastOne()
{
    var i;
    var j=0;
    for(i=1;i<5;i++)
	{
		if(document.frmprth_0.elements["photo_"+i].value=='')
		{
			j++;
		}
	}
	if (j==4)
	{
	    alert("Please upload atleast one Photo")
	    return false;
	}
	else
	{
	    return true;
	}
}
function VideoUploadValidation()
{
    if(!CheckVideoExt()) return false;
    if(!fill_title(document.frmprth_0.elements["photo_1"],"Video")) return false;
    return true;
}
function CheckVideoExt()
{
    var obj=document.frmprth_0;
    if(obj.elements["photo_1"].value!="")
    {
        pos=obj.elements["photo_1"].value.lastIndexOf(".");
		len=obj.elements["photo_1"].value.length;
		ext=obj.elements["photo_1"].value.substring(pos+1,len).toLowerCase();
		if(ext!="mpeg" && ext!="mpg" && ext!="avi" && ext!="wmv")
		{
			alert("Video file is not supported. \n\n Only mpeg,mpg,avi and wmv extension are supported");
			return false;
		}
    }
    else
    {
        alert("Please Upload Video File")
        return false;
    }
    
    if(obj.image_for_video_1.value!="")
    {
        pos=obj.image_for_video_1.value.lastIndexOf(".");
		len=obj.image_for_video_1.value.length;
		ext=obj.image_for_video_1.value.substring(pos+1,len).toLowerCase();
		if(ext!="gif" && ext!="jpg" && ext!="jpeg" && ext!="jpe")
		{
			alert("Image file is not supported. \n\n Only gif,jpg,jpeg and jpe extension are supported");
			return false;
		}
    }
    return true;
}
function AudioUploadValidation()
{
    if(!CheckAudioExt()) return false;
    if(!fill_title(document.frmprth_0.elements["photo_1"],"Audio")) return false;
    return true;
}
function CheckAudioExt()
{
    var obj=document.frmprth_0;
    if(obj.elements["photo_1"].value!="")
    {
        pos=obj.elements["photo_1"].value.lastIndexOf(".");
		len=obj.elements["photo_1"].value.length;
		ext=obj.elements["photo_1"].value.substring(pos+1,len).toLowerCase();
		if(ext!="wav" && ext!="snd" && ext!="avi" && ext!="mp3")
		{
			alert("Audio file is not supported. \n\n Only mp3,wav,avi and snd extension are supported");
			return false;
		}
    }
    else
    {
        alert("Please Upload Audio File")
        return false;
    }
    return true;
}
function fill_title(obj,caption)
{
	var objphotoname = obj.name;
	var CatName = '';
	var CapName = '';
	if(objphotoname=='photo_1')  { CatName = 'category_1'; CapName = 'caption_1'; }
	if(objphotoname=='photo_2')  { CatName = 'category_2'; CapName = 'caption_2'; }
	if(objphotoname=='photo_3')  { CatName = 'category_3'; CapName = 'caption_3'; }
	if(objphotoname=='photo_4')  { CatName = 'category_4'; CapName = 'caption_4'; }
	if(obj.value!='')
	{
	    if(document.frmprth_0.elements[CapName].value=='')
	    {
	        alert('Please specify caption for ' + caption);
	        document.frmprth_0.elements[CapName].focus();
	        return false;
	    }
        var i=1;
        var sts = false;
        
        for(i=1;i<document.frmprth_0.elements[CatName].options.length;i++)
        {
            if(document.frmprth_0.elements[CatName].options[i].selected==true)
            {
                sts=true; break;
            }
        }
        if(!sts)
        {
           alert('Please specify Category for ' + caption); 
           document.frmprth_0.elements[CatName].focus();
           return false;
        }
        return true;
	}
	return true;
}
function SetNavigation(act)
{
    cpage=document.frmprth_0.prth_cpage_0.value;
    if(act=="next")
        document.frmprth_0.prth_cpage_0.value=parseInt(cpage)+1;
    else
        document.frmprth_0.prth_cpage_0.value=parseInt(cpage)-1;
    document.frmprth_0.submit();
}
function chk_blank_pwd(frm)
{
    if(frm.password.value=="")
	{
		alert("Please Enter Valid Password");
		frm.password.focus();
		return false;
	}
	return true;
}
function SetNewsDivPosition()
{
    try
    {
    if(screen.availWidth>800)
        rssnews_divid.style.left="770px";
    }
    catch(e){ }
}

function html_newscontenteditor(oEdit1,newscatid,photocatid,isnews,isphotoblog)
{
    oEdit1.arrCustomButtons=[["ButtonName1","AddNewsinEditor('oEdit1','"+newscatid+"');","News Feed","news_info.gif"],
    ["ButtonName2","AddPhotobloginEditor('oEdit1','"+photocatid+"');","Photo Blog","photo_blog.gif"],
    ["ButtonName3","AddVideobloginEditor('oEdit1','"+photocatid+"');","Video Blog","video_blog.gif"],
    ["ButtonName4","AddAudiobloginEditor('oEdit1','"+photocatid+"');","Audio Blog","video_blog.gif"],
    ["ButtonName5","AddMiniCalinEditor('oEdit1','"+photocatid+"');","Mini Calendar","mini_calendar.gif"]];

	if(isnews)
		oEdit1.features=["FullScreen","Preview","Search","SpellCheck","|","Cut","Copy","Paste","PasteWord","|","Undo","Redo","|","ForeColor","BackColor","|","Bookmark","Hyperlink","Image","Flash","|","Table","|","Characters","Line","RemoveFormat","StyleAndFormatting","|","ButtonName1","BRK","CustomTag","Paragraph","FontName","FontSize","|","Bold","Italic","Underline","|","JustifyLeft","JustifyCenter","JustifyRight","JustifyFull","|","Numbering","Bullets","|","Indent","Outdent","|","HTMLSource"];
	
	if(isphotoblog)
	    oEdit1.features=["FullScreen","Preview","Search","SpellCheck","|","Cut","Copy","Paste","PasteWord","|","Undo","Redo","|","ForeColor","BackColor","|","Bookmark","Hyperlink","Image","Flash","|","Table","|","Characters","Line","RemoveFormat","StyleAndFormatting","|","ButtonName2","BRK","CustomTag","Paragraph","FontName","FontSize","|","Bold","Italic","Underline","|","JustifyLeft","JustifyCenter","JustifyRight","JustifyFull","|","Numbering","Bullets","|","Indent","Outdent","|","HTMLSource"];
	
	if(isnews && isphotoblog)
	    oEdit1.features=["FullScreen","Preview","Search","SpellCheck","|","Cut","Copy","Paste","PasteWord","|","Undo","Redo","|","ForeColor","BackColor","|","Bookmark","Hyperlink","Image","Flash","|","Table","|","Characters","Line","RemoveFormat","StyleAndFormatting","|","ButtonName1","ButtonName2","ButtonName3","ButtonName4","ButtonName5","BRK","CustomTag","Paragraph","FontName","FontSize","|","Bold","Italic","Underline","|","JustifyLeft","JustifyCenter","JustifyRight","JustifyFull","|","Numbering","Bullets","|","Indent","Outdent","|","HTMLSource"];
	
	if(!isnews && !isphotoblog)
	    html_contenteditor(oEdit1)
	
	oEdit1.btnCustomTag=true;
}
function html_contenteditor(oEdit1)
{

	photocatid=0;
	newscatid=0;
	/*oEdit1.arrCustomButtons=[["ButtonName1","AddNewsinEditor('oEdit1','"+newscatid+"');","News Feed","news_info.gif"],
	["ButtonName2","AddPhotobloginEditor('oEdit1','"+photocatid+"');","Photo Blog","photo_blog.gif"],
	["ButtonName3","AddVideobloginEditor('oEdit1','"+photocatid+"');","Video Blog","video_blog.gif"],
	["ButtonName4","AddMiniCalinEditor('oEdit1','"+photocatid+"');","Mini Calendar","mini_calendar.gif"]];
	*/
	oEdit1.arrCustomTag=[["Photos","AddPhotobloginEditor('oEdit1','0');"],["Video","AddVideobloginEditor('oEdit1','0');"],["Audio","AddAudiobloginEditor('oEdit1','0');"],["News","AddNewsinEditor('oEdit1','0');"],["Mini Calendar","AddMiniCalinEditor('oEdit1','0');"],["Quick Search","AddQSFinEditor('oEdit1','0');"]];
	oEdit1.features=["FullScreen","Preview","Search","SpellCheck","|","Cut","Copy","Paste","PasteWord","|","Undo","Redo","|","ForeColor","BackColor","|","Bookmark","Hyperlink","Image","Media","Flash","|","Table","|","Characters","Line","RemoveFormat","StyleAndFormatting","HTMLSource","BRK","CustomTag","Paragraph","FontName","FontSize","|","Bold","Italic","Underline","|","JustifyLeft","JustifyCenter","JustifyRight","JustifyFull","|","Numbering","Bullets","|","Indent","Outdent"];
	//oEdit1.features=["FullScreen","Preview","Search","SpellCheck","|","Cut","Copy","Paste","PasteWord","|","Undo","Redo","|","ForeColor","BackColor","|","Bookmark","Hyperlink","Image","Flash","|","Table","|","Characters","Line","RemoveFormat","StyleAndFormatting","|","ButtonName1","ButtonName2","ButtonName3","ButtonName4","BRK","Paragraph","FontName","FontSize","|","Bold","Italic","Underline","|","JustifyLeft","JustifyCenter","JustifyRight","JustifyFull","|","Numbering","Bullets","|","Indent","Outdent","|","HTMLSource"];
	oEdit1.btnCustomTag=true;
	/*
	oEdit1.features=["FullScreen","Preview","Search","SpellCheck","|","Cut","Copy","Paste","PasteWord","|","Undo","Redo","|","ForeColor","BackColor","|","Bookmark","Hyperlink","Image","Flash","|","Table","|","Characters","Line","RemoveFormat","StyleAndFormatting","BRK","CustomTag","Paragraph","FontName","FontSize","|","Bold","Italic","Underline","|","JustifyLeft","JustifyCenter","JustifyRight","JustifyFull","|","Numbering","Bullets","|","Indent","Outdent","|","HTMLSource"];
	oEdit1.btnCustomTag=false;*/
}
function AddQSFinEditor(oEdit1,catid)
{
	ShowDialogForNews('crm/quick_search_ineditor.aspx?catid='+catid,500,300);
}
function AddNewsinEditor(oEdit1,catid)
{
    //window.showModelessDialog('rssnews_ineditor.aspx?catid='+catid,[window,'oEdit1'],'dialogWidth:450px;dialogHeight:260px;edge:Raised;center:1;help:0;resizable:1;')
    ShowDialogForNews('crm/rssnews_ineditor.aspx?catid='+catid,450,260);
}
function AddPhotobloginEditor(oEdit1,catid)
{
    //window.showModelessDialog('photoblog_ineditor.aspx?catid='+catid,[window,'oEdit1'],'dialogWidth:500px;dialogHeight:400px;edge:Raised;center:1;help:0;resizable:1;')
    ShowDialogForNews('crm/photoblog_ineditor.aspx?catid='+catid,500,400);
}
function AddVideobloginEditor(oEdit1,catid)
{
    ShowDialogForNews('crm/videoblog_ineditor.aspx?catid='+catid,500,420);
}
function AddAudiobloginEditor(oEdit1,catid)
{
    ShowDialogForNews('crm/audioblog_ineditor.aspx?catid='+catid,500,420);
}
function AddMiniCalinEditor(oEdit1,catid)
{
    ShowDialogForNews('crm/minical_ineditor.aspx?catid='+catid,500,400);
}
function SetAddToNewsControl(selval)
{
    frmobj=document.frmprth_0
    if(frmobj.urgent_flag)
    {
        if(selval==1)
        {
            frmobj.urgent_flag.disabled=false;
            //frmobj.hide_from_all_news_category.disabled=false;
            frmobj.news_category.disabled=false;
            frmobj.activate_before_event_type.disabled=false;
            frmobj.activate_before_event.disabled=false;
        }
        else
        {
            frmobj.urgent_flag.disabled=true;
            //frmobj.hide_from_all_news_category.disabled=true;
            frmobj.news_category.disabled=true;
            frmobj.activate_before_event_type.disabled=true;
            frmobj.activate_before_event.disabled=true;
        }
    }
}
function SetAddToNewsTemp(obj)
{
    if(obj.checked)
        SetAddToNewsControl(1)
    else
        SetAddToNewsControl(0)
}
function CheckAddToNews(frmobj,act)
{
    if(frmobj.add_to_news.checked)
    {
        if(!NotBlank(frmobj.news_category,"News Category")) return false;
    }
    if(act!="")
    {
        frmobj.prth_act_0.value=act;
        return true;
    }
    return true;
}
function RedirectOnCalendarPage(objid,frmname,act,orderby,cpage,systemextra)
{
		
	var objfrm=eval("document." + frmname);
	
	objfrm.elements["prth_act_"+objid].value=act;
 
	objfrm.elements["prth_orderby_"+objid].value=orderby;
	
	objfrm.elements["prth_cpage_"+objid].value=cpage;
	
	if(systemextra)
		objfrm.elements["prth_system_extra_"+objid].value=systemextra;
	
	objfrm.action="calendar_edit.aspx";
	objfrm.submit();
}
function Check_CheckboxSelection(objfld)
{
    var bool=false;
    if(objfld)
    {
        if(objfld.length)
        {
            for(i=0;i<objfld.length;i++)
			{
				
				if(objfld[i].checked)
				{
					bool=true;
					break;
				}
			}
        }
        else
		{
			if(objfld.checked)
			{
				bool = true;
			}
		}
		
    }
    return bool
}
function check_selctallevents(frmobj)
{
    if(!Check_CheckboxSelection(frmobj.sel_eventsid))
    {
        alert("Please select atleast one event to perform an action");
        frmobj.flt_action_menu.value = "";
        return false; 
    }
    if (frmobj.flt_action_menu.value == "eid_delete")
    {
         if (confirm("Are you sure you want to delete selected events?"))
	    {
		    frmobj.prth_act_0.value="change_action_menu";
            frmobj.submit();
            return true;
		} 
    }
    else if(frmobj.flt_action_menu.value == "hide" || frmobj.flt_action_menu.value == "clear")
    {
        frmobj.prth_act_0.value="change_action_menu";
        frmobj.submit();
        return true;
    }
    frmobj.flt_action_menu.value = "";
	return false;
}
function check_selctallnews(frmobj)
{
    if(!Check_CheckboxSelection(frmobj.sel_newsid))
    {
        alert("Please select atleast one News to perform an action");
        frmobj.flt_action_menu.value = "";
        return false; 
    }
    if (frmobj.flt_action_menu.value == "newsid_delete")
    {
         if (confirm("Are you sure you want to delete selected News?"))
	    {
		    frmobj.prth_act_0.value="change_action_menu";
            frmobj.submit();
            return true;
		} 
    }
    frmobj.flt_action_menu.value = "";
	return false;
}

function prth_calendar_fnc_nevigation(objid,frmname,act,systemextra,seldate)
{
	
	var objfrm=eval("document." + frmname);
	objfrm.elements["prth_act_"+objid].value=act;
	objfrm.elements["prth_seldate_"+objid].value=seldate;
 	if(systemextra)
		objfrm.elements["prth_system_extra_"+objid].value=systemextra;
		
	objfrm.submit();
}
function confirmdeleteevent(objfrm)
{
    if(confirm("Do you want to delete opened calendar event?"))
    {
        objfrm.prth_act_0.value='delete';
        return true;
    }
    return false
}
function Cancleevent(objfrm)
{
    objfrm.prth_act_0.value="cancel";
    objfrm.submit();
}
function saveaspagetemplate(objfrm)
{
    if(objfrm.templateid.value=="")
    {
        boolvar = prompt("Please enter new Page Template name","","");
	    if (boolvar)
	    {
	        objfrm.prth_act_0.value="saveastemplate";
	        objfrm.templatename.value=boolvar;
	        return true;
	    }
	}
	else if(objfrm.isglobal.value==1)
	{
	    if(Templateeditmsg())
	    {
	        boolvar = prompt("Please enter new Page Template name","","");
	        if (boolvar)
	        {
	            objfrm.prth_act_0.value="saveastemplate";
	            objfrm.templatename.value=boolvar;
	            objfrm.savenewitem.value="addnew";
	            return true;
	        }
	        else
	            return false;
	     }
	}
	else
	{
	    objfrm.prth_act_0.value="saveastemplate";
	    return true;
	}
	return false;
}
function Templateeditmsg()
{
    if(confirm("Sorry! you have not permission to edit this Global Template. You can edit only own created template.\n\nIf you want to save this template as new template, click OK."))
    {
        return true;
    }
    return false
}
function template_delete(objfrm)
{
    if(objfrm.templateid.value!="")
    {
        if(confirm("Do you want to delete selected page content template?"))
        {
            objfrm.prth_act_0.value="deletetemplate";
            objfrm.submit();
            return true;
        }
    }
    else
    {
        alert("Please select page content template to delete");
    }
    return false;
}
function copytoother_textboxes(frmobj)
{
   for(i=2;i<=4;i++)
   {
        frmobj.elements["caption_"+i].value=frmobj.caption_1.value;
        frmobj.elements["category_"+i].value=frmobj.category_1.value;
        frmobj.elements["date_"+i].value=frmobj.date_1.value;
        for(j=0;j<frmobj.elements["allow_comments_1"].length;j++)
	    {
		    frmobj.elements["allow_comments_"+i][j].checked=frmobj.elements["allow_comments_1"][j].checked;
	    }
	    for(j=0;j<frmobj.elements["send_comment_email_1"].length;j++)
	    {
		    frmobj.elements["send_comment_email_"+i][j].checked=frmobj.elements["send_comment_email_1"][j].checked;
	    }
	}
}
function blog_contenteditor(oEdit1)
{
   oEdit1.features=["Undo","Redo","|","ForeColor","BackColor","|","Hyperlink","Image","Flash","Line","|","FontName","FontSize","|","Bold","Italic","Underline","|","JustifyLeft","JustifyCenter","JustifyRight","JustifyFull","|","Numbering","Bullets","|","Indent","Outdent"];
   oEdit1.height=300;
   oEdit1.btnCustomTag=false;
}
function hideshow_archivearea(id)
{
    var imgobj=document.getElementById("img_"+id)
    var divobj=document.getElementById(id)
    if(imgobj.src.indexOf("minus")>-1)
    {
        imgobj.src="images/plus.gif"
        divobj.style.display='none';
    }
    else
    {
        imgobj.src="images/minus.gif"
        divobj.style.display='block';
    }
}
function ArchiveSelection(act,act_value)
{
    document.frmprth_blog.archieve_action.value=act;
    document.frmprth_blog.archieve_action_value.value=act_value;
    document.frmprth_blog.submit();
}
function CancleClick(objfrm)
{
    objfrm.prth_act_0.value='cancel';
    objfrm.submit();
}

function check_sendmassemailform(frm)
{
	if(frm.templateid.value==0)
	{
		alert("Please select Template");
		frm.templateid.focus();
		return false;
	}
	//count=0;
	//frm.progress.value=count;
	//document.all["frmviewprogress"].src="massemail_counter.html";
	//frm.submit();
}
function massemail_progressbar_start(emaillogid)
{
	/*count=0;
	document.frmprth1.progress.value=count;
	document.all["frmviewprogress"].src="email_counter.aspx?emaillogid="+emaillogid;
	frm.submit();
	
	return true;*/
}
function progressbar()
{
	document.frmprth_0.progress.value=parseInt(count);
}
function stopprocess(er)
{
	
	if(er==0)
	{
		parent.document.frmprth_0.progress.value=parent.document.frmprth_0.totalcount.value;
	}
	parent.document.all["frmviewprogress"].src="";
	
}
function CheckForgotPassword(objfrm)
{
    if(objfrm.email_address.value=='')
    {
        alert("Please Enter Email Address");
        return false;
    }
    objfrm.prth_act_0.value='getpassword';
    return true;
}
function delete_confirmwith_blogact(objfrm)
{
    if (delete_confirm())
    {
        objfrm.prth_act_0.value="delete";
        objfrm.submit();
    }
    return false;
}
function Check_CommentAction(frmobj)
{
    
    if(!Check_CheckboxSelection(frmobj.action_id))
    {
        alert("Please select atleast one event to perform an action");
        frmobj.flt_action_menu.value = "";
        return false; 
    }
    if (frmobj.flt_action_menu.value == "allow_comment")
    {
        if (confirm("Are you sure you want allow comment?"))
	    {
		    frmobj.prth_act_0.value="change_action_menu";
            frmobj.submit();
            return true;
		}
	}
	if (frmobj.flt_action_menu.value == "disallow_comment")
	{
		if (confirm("Are you sure you want disallow comment?"))
	    {
		    frmobj.prth_act_0.value="change_action_menu";
            frmobj.submit();
            return true;
		}  
    }
    if (frmobj.flt_action_menu.value == "")
    {
        alert("Please select atleast one action")
        return false;
    }
}
function openmediaplayer(divid,path,width,height)
{
	objdiv=document.getElementById(divid);
	objdiv.innerHTML = mediaplayerstring(path,width,height);
}
function mediaplayerstring(filename,width,height)
{
	html = '<object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" id="mp_811966932" width="'+width+'" height="'+height+'" CODEBASE="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715"';
	html += ' standby="Loading Microsoft Windows Media Player components..."  ';
	html += ' TYPE="application/x-oleobject" >';
	html += ' 	<param name="Filename" value="'+filename+'"> ';
	html += '	<param name="AllowChangeDisplaySize" value="0"> ';
	html += '	<param name="AutoRewind" value="0"> ';
	html += '	<param name="Autosize" value="1"> ';
	html += '	<param name="AutoStart" value="1"> ';
	html += '	<param name="Volume" value="-500">  ';
	html += '	<param name="BufferingTime" value="3"> ';
    html += '   <embed type="application/x-mplayer2" src="'+filename+'" height="'+height+'" width="'+width+'" id="nolplayer1" name="mediaPlayerObject" showcontrols="1" showdisplay="0" autostart="1" showstatusbar="0" showstatusbar="0"> ';
	html += '</object>';
	return html;
}
function DeleteProductFromCart(objid,frmname,act,orderby,cpage,editid)
{
    if(delete_confirm("this Product from cart"))
	{
	    prth_system_fnc_nevigation(objid,frmname,act,orderby,cpage,editid);
	}
}
function addtocart_nevigation(objid,frmname,act,FieldName,systemextra)
{
  	
  	var objfrm=eval("document." + frmname);
	if (objfrm.elements[FieldName])
	{
        if (objfrm.elements[FieldName].value =='')
        {
            alert("Please select Available Option");
            return false;
        }
	}
	objfrm.elements["prth_act_"+objid].value=act;
	if(systemextra)
		objfrm.elements["prth_system_extra_"+objid].value=systemextra;

	return true;
}
function Gobacktocatalogpage(objid,frmname,act,tabid)
{
	var objfrm=eval("document." + frmname);
	objfrm.elements["prth_act_"+objid].value=act;
	document.location.replace("index.aspx?tabid="+tabid)
	//objfrm.submit();
}

function checkout_step1_buynow(frmobj,isshipping)
{
    if(Quantityrefresh(frmobj,'Buy Now...')==true)
    {
        frmobj.prth_act_sc.value='refresh';
        return true;
    }
    if(isshipping=="False")
    {
        frmobj.prth_act_sc.value='buy_now';
        return true;
    }
    if(frmobj.shipping_method)
    {
        if(frmobj.shipping_method.value=="")
        {
            alert("Please select shipping method from the above popup menu.");
            return false;
        }
        else
        {
            frmobj.prth_act_sc.value='buy_now';
            return true;
        }
    }
    else
    {
        alert("Sorry! there is no shipping method and that's why you will not buy these items. Please contact site administrator to purchase.");
        return false;
    }
}
function check_discount(frmobj)
{
    if(frmobj.discount_code.value=="")
    {
        alert("Please enter Discount code");
        return false;
    }
    else
    {
        frmobj.prth_act_sc.value='apply_discount';
        return true;
    }
}
function Print_Invoice(pagename)
{
    open_dialogbox(pagename,765,550,'yes','yes');
}
function search_keyword(frmobj,cap)
{
	if(frmobj.search_term.value=="")
	{
		alert("Please enter search term");
		return false;
	}
	if(frmobj.prth_cpage_page_se)
	    frmobj.prth_cpage_page_se.value=1;
	  
	return true;
}
function generate_media_preview(path)
{
	if(path=="")
		return;

	mid = path.substring(0,path.indexOf("_"))
	path = path.substring(path.indexOf("_")+1);

	var textpath=document.frmprth_0.sitepath.value;
	switch (document.frmprth_0.media_type.value)
	{
		case "Location":
			textpath = path;
			break;
		case "Managed URLs":
			textpath = path;
			break;
		case "Download":
			textpath = textpath+'download/'+path;
			path='../download/'+path;
			break;
		case "Image file":
			textpath = textpath+'photoblog/'+path;
			path='../photoblog/'+path;
			break;
		case "Video file": 
			textpath = textpath+'videoblog/'+path;
			path="no_preview.html";
			break;
		case "Audio file":
			textpath = textpath+'audioblog/'+path;
			path="no_preview.html";
			break;
	}
	//refid = mid+'_'+document.frmprth_0.media_type.value;
	ajaxfnc('0','','fetchtitle',"media_type,media_items",'');
   	document.frmprth_0.media_text.value=xmlHttp.responseText;//document.frmprth_0.media_items[document.frmprth_0.media_items.selectedIndex].text;
	document.all["ifrm_media_preview"].src=path;
}
function generate_Imagemedia_preview(path)
{
	if(path=="")
		return;

	mid = path.substring(0,path.indexOf("_"))
	path = path.substring(path.indexOf("_")+1);

	var textpath=document.frmprth_0.sitepath.value;
	switch (document.frmprth_0.media_type.value)
	{
		case "Image file":
			textpath = textpath+'photoblog/'+path;
			path='../photoblog/'+path;
			break;
		case "Video file": 
			textpath = textpath+'videoblog/'+path;
			path="no_preview.html";
			break;
		case "Audio file":
			textpath = textpath+'audioblog/'+path;
			path="no_preview.html";
			break;
	}
	//refid = mid+'_'+document.frmprth_0.media_type.value;
	//ajaxfnc('0','','fetchtitle',"media_type,media_items",'');
   	document.frmprth_0.media_text.value=textpath;
	document.all["ifrm_media_preview"].src=path;
}
function apply_media()
{
	path = document.frmprth_0.media_items.value;
	
	mid = path.substring(0,path.indexOf("_"))
	path = document.frmprth_0.media_text.value;
	
	refid = mid+'_'+document.frmprth_0.media_type.value;
	if(path!="")
	{
		window.opener.document.getElementById("inpRefId").value = refid;
		window.opener.document.getElementById("inpURL").value = path;
		window.opener.ManageField(path);
		window.opener.document.getElementById("inpTitle").value=document.frmprth_0.media_items[document.frmprth_0.media_items.selectedIndex].text;
		self.close();
	}
	else
	{
		alert("Please select media file");
	}
}
function apply_Imagemedia()
{
	path = document.frmprth_0.media_text.value;
	if(path!="")
	{
		if(document.frmprth_0.media_type.value=="Image file")
		{
			window.opener.document.getElementById("inpImgURL").value = path;
			//window.opener.document.getElementById("inpImgMediaType").value = document.frmprth_0.media_type.value;
			window.opener.document.getElementById("inpImgAlt").value=document.frmprth_0.media_items[document.frmprth_0.media_items.selectedIndex].text;
		}
		else
		{
			window.opener.document.getElementById("inpURL").value = path;
		}
		self.close();
	}
	else
	{
		alert("Please select media file");
	}
}
function UploadMedia()
{
	file_ext="";
	switch (document.frmprth_0.media_type.value)
	{
		case "Image file":
			file_ext="gif,jpg,jpeg,jpe";
			file_ext_cap = "gif, jpg, jpeg and jpe";
			break;
		case "Video file": 
			file_ext="mpeg,mpg,avi,wmv";
			file_ext_cap = "mpeg, mpg, avi and wmv";
			break;
		case "Audio file":
			file_ext="mp3,wav,snd,avi";
			file_ext_cap = "mp3, wav, snd and avi";
			break;
	}
	if(!CheckFileExtension(document.frmprth_0,"media_file",file_ext,file_ext_cap)) return false;
	if(document.frmprth_0.media_caption.value=="")
	{
		alert("Please enter Caption");
		return false;
	}
	if(document.frmprth_0.media_category.value=="")
	{
		alert("Please select Category");
		return false;
	}
	document.frmprth_0.prth_act_0.value="upload";
	document.frmprth_0.submit();
}
function CheckFileExtension(obj,FieldName,extensionList,extensionList_cap)
{
	if(obj.elements[FieldName].value!="")
    {
        pos=obj.elements[FieldName].value.lastIndexOf(".");
		len=obj.elements[FieldName].value.length;
		ext=obj.elements[FieldName].value.substring(pos+1,len).toLowerCase();
		bool=false;
		var extValues = extensionList.split(",");
		for(i=0;i<extValues.length;i++)
		{
			if(ext==extValues[i])
			{
				bool=true;
				break;
			}
		}
		if(!bool)
		{
			alert("Only "+extensionList_cap+" extension are supported");
			return false;
		}
    }
    else
    {
        alert("Please browse the file to upload")
        return false;
    }
	return true;
}
function Quantityrefresh(frm,btn_msg)
{
    if(keypress==true)
    {
        alert("You have made a change to the checkout amount, the checkout page will be refreshed now. Please check the new amount and press the "+btn_msg+" button again.");
        return true
    }
    return false;
}
function ContinueProc(frm)
{
    if(Quantityrefresh(frm,'Continue')==true)
    {
        frm.prth_act_sc.value='refresh';
    }
    else
    {
        frm.prth_act_sc.value='continue';
    }
    return true;
}
function CheckImageExtension(frm)
{
	extensionList="jpg,gif,jpeg,jpe"
	if(frm.elements["picture"].value!="")
    {
        pos=frm.elements["picture"].value.lastIndexOf(".");
		len=frm.elements["picture"].value.length;
		ext=frm.elements["picture"].value.substring(pos+1,len).toLowerCase();
		bool=false;
		var extValues = extensionList.split(",");
		for(i=0;i<extValues.length;i++)
		{
			if(ext==extValues[i])
			{
				bool=true;
				break;
			}
		}
		if(!bool)
		{
			alert("Only jpg,gif,jpeg,jpe extension are supported");
			return false;
		}
    }
 	return true;
}