//////////// 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');"],["Catalog","AddCataloginEditor('oEdit1','0');"],["Location URL","AddLocationinEditor('oEdit1','0');"],["DownLoad URL","AddDownLoadinEditor('oEdit1','0');"],["Managed URL","AddManagedinEditor('oEdit1','0');"],["Documents","AddDocumentinEditor('oEdit1','0');"],["Tables","AddTablesinEditor('oEdit1','0');"],["Forms","AddFormsinEditor('oEdit1','0');"],["FAQ","AddFAQinEditor('oEdit1','0');"],["Forum","AddForuminEditor('oEdit1','0');"],["Article","AddArticleinEditor('oEdit1','0');"],["WIKI","AddWIKIinEditor('oEdit1','0');"],["Support Ticket","AddTicketinEditor('oEdit1','0');"],["Quick Login","AddQuickLogininEditor('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","CSSSource_User","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 AddCataloginEditor(oEdit1,catid)
{
    ShowDialogForNews('admin/catalog_ineditor.aspx?catid='+catid,500,400);
}
function AddLocationinEditor(oEdit1,catid)
{
    ShowDialogForNews('admin/allurl_ineditor.aspx?type=location',450,260);
}
function AddDownLoadinEditor(oEdit1,catid)
{
    ShowDialogForNews('admin/allurl_ineditor.aspx?type=download',450,260);
}
function AddManagedinEditor(oEdit1,catid)
{
    ShowDialogForNews('admin/allurl_ineditor.aspx?type=manage',450,260);
}
function AddDocumentinEditor(oEdit1,catid)
{
    ShowDialogForNews('admin/documents_ineditor.aspx',450,260);
}
function AddQSFinEditor(oEdit1,catid)
{
	ShowDialogForNews('admin/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('admin/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('admin/photoblog_ineditor.aspx?catid='+catid,500,400);
}
function AddVideobloginEditor(oEdit1,catid)
{
    ShowDialogForNews('admin/videoblog_ineditor.aspx?catid='+catid,500,420);
}
function AddAudiobloginEditor(oEdit1,catid)
{
    ShowDialogForNews('admin/audioblog_ineditor.aspx?catid='+catid,500,420);
}
function AddMiniCalinEditor(oEdit1,catid)
{
    ShowDialogForNews('admin/minical_ineditor.aspx?catid='+catid,500,400);
}
function AddTablesinEditor()
{
    ShowDialogForNews('admin/table_ineditor.aspx?type=download',450,260);
}
function AddFormsinEditor(oEdit1,catid)
{
    ShowDialogForNews('admin/form_ineditor.aspx',450,260);
}
function AddFAQinEditor(oEdit1,catid)
{
    ShowDialogForNews('admin/faq_ineditor.aspx',500,260);
}
function AddForuminEditor(oEdit1,catid)
{
    ShowDialogForNews('admin/forum_ineditor.aspx',500,260);
}
function AddArticleinEditor(oEdit1,catid)
{
     ShowDialogForNews('admin/article_ineditor.aspx',720,360);
}
function AddWIKIinEditor(oEdit1,catid)
{
     ShowDialogForNews('admin/wiki_ineditor.aspx',720,360);
}
function AddTicketinEditor(oEdit1,catid)
{
     ShowDialogForNews('admin/ticket_ineditor.aspx',450,360);
}
function AddQuickLogininEditor(oEdit1,catid)
{
     ShowDialogForNews('admin/quick_login_ineditor.aspx',450,360);
}
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,host)
{
    var imgobj=document.getElementById("img_"+id)
    var divobj=document.getElementById(id)
    if(imgobj.src.indexOf("minus")>-1)
    {
        imgobj.src=host+"/images/plus.gif"
        divobj.style.display='none';
    }
    else
    {
        imgobj.src=host+"/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="0" 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;
        //alert(objfrm.elements["prth_system_extra_"+objid].value);
	return true;
}
function SetAddToCartFromDetails(objid,frmname,act,did,pid)
{
    var objfrm=eval("document." + frmname);
    objfrm.elements["prth_system_extra_"+objid].value=pid;
    objfrm.elements["product_detail_id_"+pid].value=did;
    objfrm.elements["prth_act_"+objid].value=act;
}
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(!CheckCartQuantity())
    {
        return false;
    }
    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
    {
        if(CheckCartQuantity())
        {
            frmobj.prth_act_sc.value='apply_discount';
            return true;
        }
        else
            return false;
    }
}
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 search_cec_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;
	  
	frmobj.submit();
}
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;
	//var hostname=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=textpath;//xmlHttp.responseText;//document.frmprth_0.media_items[document.frmprth_0.media_items.selectedIndex].text;
   	document.all["ifrm_media_preview"].src=textpath//path;
}
function generate_Imagemedia_preview(path,HostName)
{
	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+HostName+'/photoblog/'+path;
			path='../'+HostName+'/photoblog/'+path;
			break;
		case "Video file": 
			textpath = textpath+HostName+'/videoblog/'+path;
			path="no_preview.html";
			break;
		case "Audio file":
			textpath = textpath+HostName+'/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 = path.substring(path.indexOf("_")+1);
	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;
		ajaxfnc('0','','fetchtitle',"media_type,media_items",'');
		window.opener.document.getElementById("inpTitle").value=xmlHttp.responseText;//document.frmprth_0.media_items[document.frmprth_0.media_items.selectedIndex].text;
		window.opener.ManageField(path);
		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(!CheckCartQuantity())
    {
        return false;
    }
    if(Quantityrefresh(frm,'Continue')==true)
    {
        frm.prth_act_sc.value='refresh';
        return true;
    }
    else
    {
        frm.prth_act_sc.value='continue';
        return true;
    }    
}
function ResetCCInfo(frm)
{
    frm.card_holder.value='';
    frm.address.value='';
    frm.address2.value='';
    frm.city.value='';
    frm.state.value='';
    frm.state_old.value='';
    frm.zip_code.value='';
    frm.country_id.value='1';
    frm.card_type.value='';
    frm.card_number.value='';
    frm.exp_month.value='';
    frm.exp_year.value='';
    frm.cid.value='';
}
function ShowStateTextbox(frm)
{
    if(frm.state)
    {
        try
        {
            if(frm.state.value=='Other')
            {  
                state_id.style.display="inline-block"; 
            }
            else
            { 
                state_id.style.display="none";
                frm.state_old.value='';
            }
        }
        catch(e) {}
    }
}
function DoTransaction(frm,check)
{
    if(check!='')
    {
        if(frm.exp_month)
        if(!NotBlank(frm.exp_month,"Expiration Month"))return false;
    
        if(frm.exp_year)
        if(!NotBlank(frm.exp_year,"Expiration Year"))return false;
        if(frm.state)
        {
            if(frm.state.value=='Other')
            {  
               if(frm.state_old.value=='')
               {
                    alert("Please Enter Other State")
                    frm.state_old.focus();
                    return false;
               }
            }
        }
    }
    frm.prth_act_sc.value='do_transaction';
    return true;
}
function CheckSavedCartName(frm)
{
    if(frm.cart_name.value=='')
    {
        alert("Please enter saved cart name")
        frm.cart_name.focus();
        return false;
    }
    if(CheckCartQuantity())
    {
        frm.prth_act_sc.value='save_cartname';
        frm.submit();
        return true;
    }
    return false;
}
function RefreshCart(flag)
{
    if(document.frmprth_sc.cart_name)
    {
        if(document.frmprth_sc.cart_name.value!='')
        {
            if (confirm("Are you want to save items in the saved cart?"))
	        {
	           return CheckSavedCartName(document.frmprth_sc);
		        /*document.frmprth_sc.prth_act_sc.value='save_cartname';
                document.frmprth_sc.submit();
                return true;*/
		    }
        }
    }
    if(CheckCartQuantity())
    {
        document.frmprth_sc.prth_act_sc.value='refresh';
        document.frmprth_sc.submit();
    }
}
function CheckCartQuantityforSingle(objfld)
{
    if(!IsDecimal(objfld,"Quantity"))
    {
        objfld.value="";
        return false;
    }
    
    if(parseFloat(objfld.value)<=0 || objfld.value==" ")
    {
        alert("The quantity must be greater than 0");
        objfld.focus();
        return false;
    }
    return true;
}
function CheckCartQuantity()
{
    frmele = document.frmprth_sc.elements;
    for(i=0;i<frmele.length;i++)
    {
        objname = frmele[i].name.toLowerCase();
        if(objname.length>10)
        {
            objname = objname.substr(0,9);
        }
        if(objname=="quantity_")
        {
            objfld = frmele[i];
            if(!IsDecimal(objfld,"Quantity")) return false;
            
            if(parseFloat(objfld.value)<=0 || objfld.value==" ")
            {
                alert("The quantity must be greater than 0");
                objfld.focus();
                return false;
            }
        }
    }
    return true;
}
function HideShowBlock(divid,Host)
{
	if(divid!="")
	{
		objdiv=document.getElementById(divid);
		if(objdiv)
		{
			objkeydiv=eval("document.getElementById('key_" + divid + "')");
			if(objkeydiv.src.indexOf("plus") == -1 )
			{
				objdiv.style.display="none";
				objkeydiv.src=Host+"/images/plus_a.gif";
			}
			else
			{
				objdiv.style.display="block";
				objkeydiv.src=Host+"/images/minus_a.gif";
			}
		}
	}
}
function DivHideShow(id,tot_div)
{
    var i=0;
    for(i=0;i <= tot_div;i++)
    {
        objdiv=document.getElementById("div_"+i);
        if(id==i)
        {  objdiv.style.display="block";}

        else
        {  objdiv.style.display="none";}
    }
}
function MoveRowProcess(column,action)
{
    ObjFrm=document.frmprth_0;
    if(action=="up")
        ObjFrm.prth_act_0.value="row_up";
    else if(action=="down")
        ObjFrm.prth_act_0.value="row_down";

    ObjFrm.selected_table_id.value="table_1";
    ObjFrm.rowcol_index.value=column;
    ObjFrm.submit();
}
function MoveColumnProcess(column,action)
{
    ObjFrm=document.frmprth_0;
    if(action=="left")
        ObjFrm.prth_act_0.value="column_left";
    else if(action=="right")
        ObjFrm.prth_act_0.value="column_right";

    ObjFrm.selected_table_id.value="table_1";
    ObjFrm.rowcol_index.value=column;
    ObjFrm.submit();
}
function DeleteRowProcess(rowid)
{
    ObjFrm=document.frmprth_0;
    ObjFrm.rowcol_index.value=rowid;
    ObjFrm.prth_act_0.value="delete_row";
    ObjFrm.submit();
}
function AddRowBelowProcess(rowid)
{
    ObjFrm=document.frmprth_0;
    ObjFrm.rowcol_index.value=rowid;
    ObjFrm.prth_act_0.value="add_row_below";
    ObjFrm.submit();
}
function OpenTablePreview(editid)
{
    open_dialogbox("admin/preview_table.aspx?pageid="+editid,500,400,"yes","yes","no","no");
}
function EditMe(str,pageid,path)
{			
	if(InEdit!=str)
	{
		if(InEdit!="")CancelMe(InEdit);
		var links="<img border='0' src='/"+path+"/images/tableeditor/html.gif' alt='Edit HTML' onclick=SaveHTML('"+str+"','"+pageid+"');><img border='0' src='/"+path+"/images/tableeditor/ok.gif' alt='Save Edit' onclick=SaveMe('"+str+"');><img border='0' src='/"+path+"/images/tableeditor/cancelwrite.gif' alt='Cancel Edit' onclick=CancelMe('"+str+"');>";
		var divObj=eval(str);
		OldValue=divObj.innerHTML
		divObj.innerHTML="<input name='txt_"+str+"' value='"+divObj.innerHTML+"'>"+links;
		InEdit=str;
	}
}
function SaveMe(str)
{
	ObjFrm=document.frmprth_0;
	var txtval=eval("document.frmprth_0.txt_" + str).value;
	var divObj=eval(str);
	divObj.innerHTML='';
	ObjFrm.rowcol_index.value=txtval;
	ObjFrm.selected_table_id.value=str;
	ObjFrm.prth_act_0.value="save_cell";
	InEdit="";
	OldValue="";
	ObjFrm.submit();
}
function CancelMe(str)
	{
		var txtval=eval("document.frmprth_0.txt_" + str).value;		
		var divObj=eval(str);
		divObj.innerHTML=OldValue;
		InEdit="";
		OldValue="";
	}
function SaveHTML(str,PageID)
{
    open_dialogbox('edit_table_content.aspx?pageid='+PageID+'&id='+str+'',680,300,'yes','no','no',1);
}
function tableeditor_content(oEdit1)
{
	oEdit1.features=["Bold","Italic","Underline","ForeColor","BackColor","|","Undo","Redo","HTMLSource"];
}
function AddRemoveColumn(colid,action)
{
    ObjFrm=document.frmprth_0;
    ObjFrm.rowcol_index.value=colid;
    ObjFrm.prth_act_0.value=action;
    ObjFrm.submit();
}
function HtmlFormPageEditor(oEdit1)
{
	photocatid=0;
	newscatid=0;
	oEdit1.features=["FullScreen","Preview","Search","SpellCheck","|","Cut","Copy","Paste","PasteWord","|","Undo","Redo","|","ForeColor","BackColor","|","Bookmark","Hyperlink","Image","ImageMap","Media","Flash","|","Table","Form","|","Characters","Line","RemoveFormat","StyleAndFormatting","HTMLSource","BRK","Paragraph","FontName","FontSize","|","Bold","Italic","Underline","|","JustifyLeft","JustifyCenter","JustifyRight","JustifyFull","|","Numbering","Bullets","|","Indent","Outdent"];
	oEdit1.btnCustomTag=true;
}
function htmlformeditor(objFrm,btnflag,id)
{
    if(!NotBlank(objFrm.linkname,"Form Page Name")) return false;
	if(!IsNumeric(objFrm.isfranchise,"Category"))return false;
	if(btnflag=="true")
	{
	    objFrm.prth_act_0.value='savepagecontent';
	}
	else if(btnflag=="false")
	{
	    objFrm.prth_act_0.value='savebylink';
	    if(id >0)
	        { 
	            if(objFrm.moduleid)
	                open_dialogbox("form_editor_popup_portal.aspx?type=pagecontent&pageid="+id,700,500,"no","yes","no","pagecontent");     
	            else
	                location.replace("form_editor_popup_portal.aspx?pageid="+id);
	        }
	    else
	        {
	            objFrm.submit(); 
	        }
	}
	else if(btnflag=="thanks_true")
	{
	    objFrm.prth_act_0.value='savebythanks';
	    if(id >0)
	        { 
	            open_dialogbox("form_editor_popup_portal.aspx?type=thank_text&pageid="+id,700,500,"no","yes","no","pagecontent"); 
	        }
	    else
	        {
	            objFrm.submit(); 
	        }
	}
    return true;
}
function DupDocRecord(objid,frmname,act,orderby,cpage,editid)
{
	var filename = prompt("Enter Duplicate Form Name","","");
	if(filename)
    {
        var objfrm=eval("document." + frmname);
        objfrm.elements["prth_act_"+objid].value='duplicate_record';
        objfrm.elements["prth_system_extra_"+objid].value=editid+"_"+filename;
        objfrm.submit();
    }
    return false;
}
function FormDivHideShow(fieldname)
{
    if(fieldname)
    {
        if(fieldname.name=="action_type")
        {
            if(fieldname.checked==true)
               email_id.style.display="block";  
            else
               email_id.style.display="none";  
        }
        if(fieldname.name=="redirect_to")
        {
            if(fieldname.value=="" || fieldname.value=="0")
               thank_id.style.display="block";  
            else
               thank_id.style.display="none";  
        }
    }
}
function DeleteFormData(objfrm)
{
    if(delete_confirm())
	{
	    objfrm.prth_act_0.value="delete";
	    objfrm.submit();
	}
	return false;
}
function DisplyPDFContent(doc,type)
{
    open_dialogbox("view_pdfcontent.aspx?type="+type+"&docid="+doc,'770','510','yes','yes')
}
function PDFExtension(frm)
{
    if(frm.doc_name)
    {
        obj=frm.doc_name;
        if(obj.value!="")
        {
            pos=obj.value.lastIndexOf(".");
	        len=obj.value.length;
	        ext=obj.value.substring(pos+1,len).toLowerCase();
	        if(ext!="pdf")
	        {
		        alert("Only pdf extension are supported");
		        return false;
	        }
        }
        else
        {
            if(frm.prth_system_extra_0.value>0)
            {
                return true;
            }
            else
            {
                alert("Please Upload PDF Document")
                return false;
            }
            
        }
     }
}
function prth_system_forum(objid,frmname,act,systemextra,parentid)
{
	var objfrm=eval("document." + frmname);
	
	objfrm.elements["prth_act_"+objid].value=act;
 
	if(systemextra)
	{
		objfrm.elements["prth_system_extra_"+objid].value=systemextra;
		objfrm.elements["forum_post_id"].value=systemextra;
	}
	if(parentid)
		objfrm.elements["parentid"].value=parentid;
	
	objfrm.submit();
}

function DeleteForumPost(objid,frmname,act,editid)
{
	if(delete_confirm())
	{
	    prth_system_forum(objid,frmname,act,editid,0);
	}
}

function forumreplyeditor(editor)
{
   editor.css="stylesheet/Forum.css";
   editor.features=["Undo","Redo","|","ForeColor","BackColor","|","Hyperlink","Image","Flash","Line","|","FontName","FontSize","|","Bold","Italic","Underline","|","JustifyLeft","JustifyCenter","JustifyRight","JustifyFull","|","Numbering","Bullets","|","Indent","Outdent"];
}

function wikieditor(editor)
{
   editor.css="stylesheet/Wiki.css";
   editor.features=["Undo","Redo","|","ForeColor","BackColor","|","Hyperlink","Image","Flash","Line","|","FontName","FontSize","|","Bold","Italic","Underline","|","JustifyLeft","JustifyCenter","JustifyRight","JustifyFull","|","Numbering","Bullets","|","Indent","Outdent"];
}

function DocumentExtension(obj)
{
    if(obj)
    {
        if(obj.value!="")
        {
            pos=obj.value.lastIndexOf(".");
	        len=obj.value.length;
	        ext=obj.value.substring(pos+1,len).toLowerCase();
	        if(ext!="pdf" && ext!="doc" && ext!="zip" && ext!="txt")
		    {
			    alert("Only pdf,doc,zip and txt extension are supported");
			    return false;
		    }
        }
     }
     return true;
}
function CopyShippingInfo(frm)
{
    frm.shp_first_name.value = frm.first_name.value;
    frm.shp_last_name.value= frm.last_name.value;
    frm.shp_address.value= frm.address.value;
    frm.shp_city.value= frm.city.value;
    frm.shp_state.value= frm.state.value;
    frm.shp_zip_code.value= frm.zip_code.value;
    frm.shp_country_id.value= frm.country_id.value;
    frm.shp_phone.value= frm.phone.value;
}
function CheckSubscriptionPlan(field,msg)
{
    var frm = eval("document.frmprth_0");
    bool=true;
    if(frm.elements["subscriber_manage"])
	{	
		if(frm.elements["subscriber_manage"].length)
		{
			bool=false;
			for(i=0;i<frm.elements["subscriber_manage"].length;i++)
			{
				if(frm.elements["subscriber_manage"][i].checked==true)
				{
				    bool=true;
				}
			}
		}
	}
	if(bool==true)
	    {return true;}
	else
	    {
	        alert("Please Select Subscription");
	        return false;
	    }
}
function CalculateAmount(frm,action)
{
    
    if(!CheckPlanIDSelection(frm)) return false;
//    if(action=='pay_now')
//    {
//        if(frm.credit_card.value=="")
//        {
//            alert("Please Select Credit Card");
//            frm.credit_card.focus();
//            return false;
//        }
//    }
    frm.prth_act_0.value=action;
    frm.submit();
}
function CheckPlanIDSelection(frm)
{
    bool=false;
    for(i=0;i<=frm.plan_ids.length-1;i++)
    {
        if(frm.elements("plan_ids")[i].checked==true)
        {
            bool=true;
        }
    }
    if (bool==false)
    {
        alert("Please Select Subscription Plan");
        return false;
    }
    return true;
}
function CheckedRequestedPlan(ids)
{
    if(ids!="")
    {
        ids=','+ids+',';
        frm = document.frmprth_0;
        
        for(i=0;i<=frm.plan_ids.length-1;i++)
        {
            if(ids.indexOf(frm.elements("plan_ids")[i].value)>-1)
            {
                frm.elements("plan_ids")[i].checked=true;
            }
        }
    }
}
function CheckCardNumber(frm)
{
    if(!IsNumeric(frm.card_number,"Card Number"))return false;
    
    if(frm.card_number.value.length<=15)
    {
        alert("Please enter valide Credit Card Number");
        frm.card_number.focus();
        return false;
    }
    
}
function CancelPlan(objid,frmname,act,orderby,cpage,editid)
{
    if(confirm("Are you sure you want to cancel selected Plan?"))
	{
	    prth_system_fnc_nevigation(objid,frmname,act,orderby,cpage,editid);
	}
}
function PreviewTemplate(frm)
{
    if(frm.email_list_id.value=='' || frm.email_list_id.value=='0')
    {
        alert("Please Select Email List");
        frm.email_list_id.focus();
        return;            
    }
    frm.target='_blank';
    frm.action="/preview_email.aspx?templateid="+frm.templateid.value;
    frm.prth_act_0.value='';
	frm.submit();
}
function SendAllEmail(frm)
{
    frm.target='';
    frm.action='';
    frm.prth_act_0.value='save';
    return true;
}
function SendSampleEmail(frm)
{
    frm.target='';
    frm.action='';
    frm.prth_act_0.value='send_preview';
    return true;
}
function EmailListChange(frm)
{
    frm.target='';
    frm.action='';
    frm.prth_act_0.value='edit';
    frm.submit();
}
function PerformOrderBy(frm,sort,id,actionid)
{
    frm.table_sort_by.value=sort;
    frm.table_sort_id.value=id;
    frm.elements[actionid].value="sorting";
    frm.submit();
}
function changeImage(imgobj,imgname)
{
 //imgobj = document.getElementById(imgid);
 imgsrc = imgobj.src; 
 pos = imgsrc.lastIndexOf("/")+1;
 fpath = imgsrc.substring(0, pos);
 imgsrc = imgsrc.substring(imgsrc.length-imgsrc.lastIndexOf("//")-1);
 imgext = imgsrc.substring(imgsrc.lastIndexOf("."))
 imgobj.src = fpath + imgname + imgext;
}


function checkquicklogininfo(frm)
{
    if(frm.email_address.value=="" || frm.email_address.value=="Email Address")
	{
		alert("Email Address is mandatory");
		frm.email_address.focus();
		return false;
	}
	 if(frm.show_password.value=="Password")
	{
		alert("Password is mandatory");
		frm.show_password.focus();
		return false;
	}
    if(frm.password.value=="")
	{
		alert("Password is mandatory");
		frm.password.focus();
		return false;
	}
    
    return true;
}


 function callonfocus(obj,defaultvalue,formid)
{
    if(obj.value == defaultvalue)
    {
        obj.value="";
        if(defaultvalue=="Password")
        {
           document.getElementById("div_show_password_" + formid).style.display='none';
           document.getElementById("div_password_" + formid).style.display='block';
           obj.form.password.focus();
        }       
    }
}

function callonblur(obj,defaultvalue,formid)
{
    if(obj.value == "")
    {
       if(defaultvalue=="Password")
       {
           obj.form.show_password.value='Password';
           document.getElementById("div_show_password_" + formid).style.display='block';
           document.getElementById("div_password_" + formid).style.display='none';
       }
       else
        obj.value=defaultvalue;
    }
}

// Flex Control Functions - Start *************

var NewFile = "";
var OriFile = "";
var Host = "";
var re;
function UploadStarted(FileName,ORIFileName,DocumentID,TypeID)
{
    //alert('Upload Started Called...\nOriginal File Name: ' + ORIFileName + '\nNew File Name: ' + FileName);
    Host = TypeID;
    NewFile = FileName;
    re = / /g;
    OriFile = ORIFileName.replace(re, "_");
    re = /,/g;
    OriFile = OriFile.replace(re, "_");
    re = /'/g;
    OriFile = OriFile.replace(re, "_");
}

function UploadCompleted()
{
    //alert('Upload Completed Called...');
    if (OriFile != "")
    {
        if (document.getElementById("new_files") != undefined)
        {
            document.getElementById("new_files").value += OriFile + ",";
        }
        if (document.getElementById("upload_list") != undefined)
        {
            if (document.getElementById("upload_list").innerHTML.match("inline") == "inline")
            {
                document.getElementById("upload_list").innerHTML += ",&nbsp;<div id='" + OriFile + "' style='display:inline;'><a href='" + Host + "/attachments/" + OriFile + "' target='_blank' style='text-decoration:none;'>" + OriFile + "</a>&nbsp;<a href='Javascript:void(0)' style='color:red;' onclick=RemoveFile('" + OriFile + "',0)><img src='admin/images/icon_delete.gif' border='0' alt='Remove File' /></a></div>";
            }
            else
            {
                document.getElementById("upload_list").innerHTML += "<div id='" + OriFile + "' style='display:inline;'><a href='" + Host + "/attachments/" + OriFile + "' target='_blank' style='text-decoration:none;'>" + OriFile + "</a>&nbsp;<a href='Javascript:void(0)' style='color:red;' onclick=RemoveFile('" + OriFile + "',0)><img src='admin/images/icon_delete.gif' border='0' alt='Remove File' /></a></div>";
            }
        }
        NewFile = "";
        OriFile = "";
    }
}

function RemoveFile(FileName,TemplateID)
{
	//alert("RemoveFile Function Called...");
	//Are you sure you want to delete
	if (confirm("Are you sure you want to delete " + FileName + "?"))
	{
	    if (document.getElementById(FileName) != undefined && document.getElementById("upload_list") != undefined)
	    {
	        document.getElementById(FileName).style.display = "none";
	        var alldivs = document.getElementById("upload_list").innerHTML.split(",&nbsp;");
	        document.getElementById("upload_list").innerHTML = "";
	        for (i = 0; i < alldivs.length; i++)
	        {
	            document.getElementById("upload_list").innerHTML += alldivs[i];
	            var styledisplay = alldivs[i].substring(alldivs[i].indexOf(":") + 2,alldivs[i].indexOf("id") - 2);
	            if (styledisplay != "none")
	            {
	                document.getElementById("upload_list").innerHTML += ",&nbsp;";
	            }
	        }
	        document.getElementById("upload_list").innerHTML = document.getElementById("upload_list").innerHTML.substring(0, document.getElementById("upload_list").innerHTML.length - 7);
	    }
	    if (document.getElementById("new_files") != undefined)
	    {
	        var attachedfiles = document.getElementById("new_files").value;
	        attachedfiles = attachedfiles.replace(FileName + ",","");
	        document.getElementById("new_files").value = attachedfiles;
	    }
	    if (document.getElementById("hd_filename") != undefined && document.getElementById("hd_templateid") != undefined)
	    {
	        document.getElementById("hd_filename").value = FileName;
	        document.getElementById("hd_templateid").value = TemplateID;
	        ajaxfnc("0","email_template.aspx","RemoveAttachments","hd_filename,hd_templateid","temp");
	    }
	}
}

function RemoveTempFile(FileName,TemplateID)
{
	//alert("RemoveTempFile Function Called...");
	//Are you sure you want to delete
	if (confirm("Are you sure you want to delete " + FileName + "?"))
	{
	    var attachedfiles = "";
	    if (document.getElementById("new_files") != undefined)
	    {
	        attachedfiles = document.getElementById("new_files").value;
	        attachedfiles = attachedfiles.replace(FileName + ",","");
	        document.getElementById("new_files").value = attachedfiles;
	    }
	    if (document.getElementById(FileName) != undefined && document.getElementById("upload_list") != undefined)
	    {
	        document.getElementById(FileName).style.display = "none";
	        var alldivs = document.getElementById("upload_list").innerHTML.split(",&nbsp;");
	        document.getElementById("upload_list").innerHTML = "";
	        for (i = 0; i < alldivs.length; i++)
	        {
	            document.getElementById("upload_list").innerHTML += alldivs[i];
	            var styledisplay = alldivs[i].substring(alldivs[i].indexOf(":") + 2,alldivs[i].indexOf("id") - 2);
	            if (styledisplay != "none")
	            {
	                document.getElementById("upload_list").innerHTML += ",&nbsp;";
	            }
	        }
	        document.getElementById("upload_list").innerHTML = document.getElementById("upload_list").innerHTML.substring(0, document.getElementById("upload_list").innerHTML.length - 7);
	    }
	}
}
// Flex Control Functions - End ***************
function CreditCardBackLink(url)
{
    url = url.replace("https://","http://")
    document.location.replace(url);
}