// JScript File

//Common Functions.
/////////////////////////////////////////////////////////
//Removes left and right hand side spaces from the given
//string.
/////////////////////////////////////////////////////////
function Trim(tstrInput)
{
	return (tstrInput.replace(/^ *| *$/g,""));
}
function GetControlId( sCtlId )
{
	strId  = new String( sCtlId );
	lstInd = strId.lastIndexOf("_");
	strId  = strId.substring( 0 , lstInd+1 );
	return strId;
}

	
//End.

/////////////////////////////////////////////////////////
//Check the client side validations before page submits.
/////////////////////////////////////////////////////////
function fnCheckValidation( sClientId )
{
    var objPortalName   =   document.getElementById( sClientId + "_txtPortalName");
    var objBrideName    =   document.getElementById( sClientId + "_txtBrideName");
    var objBrideLastName=   document.getElementById( sClientId + "_txtBrideLastName");
    var objGroomName    =   document.getElementById( sClientId + "_txtGroomName");
    var objGroomLastName=   document.getElementById( sClientId + "_txtGroomLastName");
    var objFirstName    =   document.getElementById( sClientId + "_txtFirstName");
    var objLastName     =   document.getElementById( sClientId + "_txtLastName");
    var objUserName     =   document.getElementById( sClientId + "_txtUserName");
    var objEmail        =   document.getElementById( sClientId + "_txtEmail");
    var objWeddingCS    =   document.getElementById( sClientId + "_txtWeddingCS");
    
    var _BrideName    =   document.getElementById("_hidBrideName").value;
    var _BrideLastName=   document.getElementById("_hidBrideLastName").value;
    var _GroomName    =   document.getElementById("_hidGroomName").value;
    var _GroomLastName=   document.getElementById("_hidGroomLastName").value;
    var _WeddingCS   =  document.getElementById("_hidWeddingCS").value;
    
    document.getElementById(sClientId + "_lblMessage").innerHTML = "";
    
//Check required fields validations.Domain Site Information
    if( Trim( String(objPortalName.value) ) == "" ||  objPortalName.value == "Domain Name")
    {
        objPortalName.focus();
        return false;       
    }
    
    if( Trim( String(objGroomName.value) ) == "" || objGroomName.value == _GroomName)
    {
        objGroomName.focus();
        return false;
    }
    
    if( Trim( String(objGroomLastName.value) ) == "" || objGroomLastName.value == _BrideLastName)
    {
        objGroomLastName.focus();
        return false;
    }
    
    if( Trim( String(objBrideName.value) ) == "" || objBrideName.value == _BrideName)
    {
      objBrideName.focus();
        return false;
    }
    
    if( Trim( String(objBrideLastName.value) ) == "" || objBrideLastName.value == _BrideLastName )
    {
        objBrideLastName.focus();
        return false;
    }  
        //Check required fields validations.Account Information
    if( Trim( String(objFirstName.value) ) == "" || objFirstName.value == "First Name")
    {
        objFirstName.focus();
        return false;
    }  
    
    if( Trim( String(objLastName.value) ) == "" || objLastName.value == "Last Name" )
    {
        objLastName.focus();
        return false;
    }
    
    if( Trim( String(objUserName.value) ) == "" || objUserName.value == "User Name")
    {
        objUserName.focus();
        return false;
    }
    
    if( Trim( String(document.getElementById( sClientId + "_txtPassword").value) ) == "" )
    {
        document.getElementById( sClientId + "_txtPassword").value  = "";
        HidePasswordSpan(  sClientId + "_txtPasswordback" ,  sClientId + "_txtPassword" );
        return false;
    }
    
    if( Trim( String(document.getElementById( sClientId + "_txtConfirm").value) ) == "" )
    {   
        document.getElementById( sClientId + "_txtConfirm").value  = "";
        HidePasswordSpan(  sClientId + "_txtConfirmBack" ,  sClientId + "_txtConfirm" );  
        return false;
    }
    
    if( Trim( String(objEmail.value) ) == "" || objEmail.value == "Email")
    {
        objEmail.focus();
        return false;
    }
    
    //Check whether usdername contains "<" or ">" character.
    if( String( objUserName.value ).indexOf("<") != -1 || String( objUserName.value ).indexOf(">") != -1  )
    {
        document.getElementById("divMessage").innerHTML = 'Username and Password fields should not contain "<" and ">" characters.';
        objUserName.focus();
        return false;
    }
    
    
    //Added By Ruchir Patel: 20070921
    //User name should contains only A-Z, a-z, 0-9, - , _ characters
    var sUsernameName = new String( objUserName.value );
    var oUN = new RegExp("^[a-zA-Z0-9-_]+$");
    
    if( oUN.test(sUsernameName) == false )
    {   
        document.getElementById("divMessage").innerHTML = "The username must not contain spaces or punctuations.";
        objUserName.focus();
        return false;
    }
    
    
    //Check whether password contains "<" or ">" character.
    if( String( document.getElementById( sClientId+ "_txtPassword" ).value ).indexOf("<") != -1 || String( document.getElementById( sClientId+ "_txtPassword" ).value ).indexOf(">") != -1 )
    {
        document.getElementById("divMessage").innerHTML = 'Username and Password fields should not contain "<" and ">" characters.';
        oPass = document.getElementById( sClientId+ "_txtPassword" );
        oConfirmPass    = document.getElementById( sClientId + "_txtConfirm" );        
        oPass.value  = "";
        oConfirmPass.value  = "";
        oPass.focus();
        return false;
    }
    
    //Check whether password and confirm password is same or not.
    if( document.getElementById( sClientId+ "_txtPassword" ).value != document.getElementById( sClientId + "_txtConfirm" ).value )
    {
        oPass           = document.getElementById( sClientId+ "_txtPassword" );
        oConfirmPass    = document.getElementById( sClientId + "_txtConfirm" );        
        oPass.value         = "";
        oConfirmPass.value  = "";
        oPass.focus();
        document.getElementById("divMessage").innerHTML = "The Password values entered do not match.";
        return false;
    }
    
    //Check Minimum password length
    var strPassword = new String( document.getElementById( sClientId + "_txtPassword").value );
    if( strPassword.length < 7 )
    {
        document.getElementById("divMessage").innerHTML = "Password should be at least 7 characters long.";
        oPass = document.getElementById( sClientId+ "_txtPassword" );
        oConfirmPass    = document.getElementById( sClientId + "_txtConfirm" );        
        
        oPass.value  = "";
        oConfirmPass.value  = "";
        oPass.focus();
        return false;
    }
    
    //Domain name should contain only Alphanumeric and '-' character only.
    
    //Modified By Ruchir Patel : 20050521 : QA_051407_vs.doc
    //Domain names should allow underscore. Ex. we can have a domain name as yaadein.com/abhi_aish
    
    var sPortalName = new String( objPortalName.value );
    var oR = new RegExp("^[a-zA-Z0-9-_]+$") ;
    
    if( oR.test( sPortalName ) == false )
    {
        document.getElementById("divMessage").innerHTML = "The domain name must not contain spaces or punctuations.";
        objPortalName.focus();
        return false;
    }
    
    //Check whether the specified email address is in correct format or not.
    var sEmail = new String( objEmail.value );
    var emailValid = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9_\.\-])+\.)+([a-zA-Z0-9]{2,4})$/;

    if( emailValid.test( sEmail ) == false)
    {
        document.getElementById("divMessage").innerHTML = "Specified email address is not in correct format.";
        objEmail.focus();
        return false;
    }

    //Check whether user has cheked the Terms conditions chekcckbox or not.    
    if( document.getElementById("chkTerms").checked == false )
    {
        document.getElementById("divMessage").innerHTML = "Please agree with Terms of Use and Privacy Policy before continuing.";
        return false;
    }
    return true;
}

function fnSetDefaultColor( sId )
{
    document.getElementById(sId + "_txtFirstName").className    = "tlog-txtbx";
    document.getElementById(sId + "_txtLastName").className     = "tlog-txtbx";
    document.getElementById(sId + "_txtUserName").className     = "tlog-txtbx";
    document.getElementById(sId + "_txtEmail").className        = "tlog-txtbx";
    document.getElementById(sId + "_txtPortalName").className   = "tlog-txtbx";
    document.getElementById(sId + "_txtGroomName").className    = "tlog-txtbx";
    document.getElementById(sId + "_txtGroomLastName").className = "tlog-txtbx";
    document.getElementById(sId + "_txtBrideName").className    = "tlog-txtbx";
    document.getElementById(sId + "_txtWeddingDate").className    = "tlog-txtbx";
    document.getElementById(sId + "_txtBrideLastName").className = "tlog-txtbx";
    document.getElementById(sId + "_dbWedding").className       = "tlog-combobx";
}

/////////////////////////////////////////////////////////
//Clear textboxes value on focus.
/////////////////////////////////////////////////////////
function SetValue(objControl , sValue)
{
    if( objControl.value  == sValue )
        objControl.value = "";
    
    objControl.select();
}


////////////////////////////////////////////////////////////////////////////////
//Create Arrya to store tooltip for each control. Show tooltip for each control.
////////////////////////////////////////////////////////////////////////////////	
var strToolTip = new Array();
function setArray()
{
strToolTip[0] = 'Enter your FIRST NAME to get started.';
strToolTip[1] = 'Please enter your LAST NAME.';
strToolTip[2] = 'Choose a USER NAME. This will be used to log on in future.';
strToolTip[3] = 'Now, set a PASSWORD. It should be at least 7 characters long.';
strToolTip[4] = 'PASSWORD again.';

strToolTip[6] = 'Set a DOMAIN NAME for your site.<BR/>Characters other than alphanumeric and underscore are not permitted.';
strToolTip[5] = 'Please enter your EMAIL ADDRESS. Worry not - we absolutely hate spam.';
    if (document.getElementById("_hidGroomName") != null && document.getElementById("_hidGroomName") != 'undefined')
    {
        strToolTip[7] = "Enter the " + document.getElementById("_hidGroomName").value.toUpperCase();
        //COMPANY NAME here.";
        strToolTip[8] = "Enter the " +  document.getElementById("_hidGroomLastName").value.toUpperCase();
        //COMPANY SLOGAN.";
        strToolTip[9] = "Enter the " + document.getElementById("_hidBrideName").value.toUpperCase();
        // COMPANY ADDRESS LINE 1.";
        strToolTip[10] = "Enter the " + document.getElementById("_hidBrideLastName").value.toUpperCase();
        //COMPANY ADDRESS LINE 2.";
        strToolTip[11] = "Enter the " + document.getElementById("_hidWeddingCS").value.toUpperCase();
    }
}
setTimeout('setArray()',500);
    
   


/////////////////////////////////////////////////////////
//Show ToolTip.
/////////////////////////////////////////////////////////
function fnToolTip( objFIrst , nIndex)
{   
    var oDiv = document.getElementById( "divTip" );
    var oifrmMenu = document.getElementById( "ifrTip" );
    
    oDiv.style.display  = "block";
    oDiv.innerHTML      = "<table width='272' height='100%' class='tooltip-txt'><tr><td valign='top' style='padding-right:5px;padding-left:5px;padding-top:5px;'>" + strToolTip[ nIndex ] + "</td></tr></table>";
 
    //Dive should be opened 40 pixel left to the textbox.
    if( parseInt( fnGetOffsetLeft( objFIrst  ) +  40 + oDiv.offsetWidth  ) > screen.width)
    {
        oDiv.style.left     = fnGetOffsetLeft( objFIrst  ) + 40 - oDiv.offsetWidth;
        oDiv.style.top      = fnGetOffsetTop( objFIrst ) - 66 ;  
        oDiv.className      = "tooltipright";
    }
    else    
    {
        oDiv.style.left     = fnGetOffsetLeft( objFIrst  ) + 40 - 15;
        oDiv.style.top      = fnGetOffsetTop( objFIrst ) - 66 ;    
        oDiv.className      = "tooltipleft";
    }

	oifrmMenu.style.left   = fnGetOffsetLeft(oDiv)
	oifrmMenu.style.top    = fnGetOffsetTop(oDiv)
	oifrmMenu.style.height = oDiv.offsetHeight;
	oifrmMenu.style.width  = oDiv.offsetWidth;
	oifrmMenu.style.display = "";
 
}

/////////////////////////////////////////////////////////
//Hide ToolTip.
/////////////////////////////////////////////////////////
function fnHideToolTip( )
{
    document.getElementById( "divTip" ).style.display = "none";
    document.getElementById( "divTip" ).className = "";
    
    var oifrmMenu = document.getElementById( "ifrTip" );
	oifrmMenu.style.display = "none";
}
	
/////////////////////////////////////////////////////////
//If user does not specify the value then assign default  
//value as a lable to the textbox.
/////////////////////////////////////////////////////////

//Modified the scripts by Ruchir Patel : 20050502 : "QA_042307_vs.doc"  
//Add scripts so that Fields that are populated must change to a different color for background.
function SetDefaultValue(objControl , sValue)
{
    if( Trim( objControl.value ) == "" )
        { objControl.value  = sValue; objControl.className  = "tlog-txtbx"; }
    else
        objControl.className  = "tlog-txtpopbx";
    
}

//Added the scripts by Ruchir Patel : 20050502 : "QA_042307_vs.doc"  
//Autofill the last name for groom or bride, by looking at the first name and matching it with the user’s first and last name.
function FillLastName( oFirst , sLast )
{
    var sId = GetControlId( oFirst.id );
    
    sUserFirst = new String( document.getElementById(sId + "txtFirstName").value );
    sUserLast  = new String( document.getElementById(sId + "txtLastName").value );
    sBGFirst   = new String( oFirst.value );
    
    if( sBGFirst.toLowerCase() == sUserFirst.toLowerCase() && sUserLast != "Surname")
        document.getElementById(sId + sLast).value = sUserLast;
}

/////////////////////////////////////////////////////////
//Clear password textboxes value on focus.
/////////////////////////////////////////////////////////
function HidePasswordSpan( sControlBackId , sControlId )
{
    document.getElementById(sControlBackId).style.display = "none";
    document.getElementById(sControlId).style.display = "block";
    document.getElementById(sControlId).focus();
    
}

/////////////////////////////////////////////////////////
//If user does not specify the password then assign default  
//value as a lable to the textbox.
/////////////////////////////////////////////////////////
function ShowPasswordSpan( sControlBackId , sControlId )
{
    var objControl = document.getElementById(sControlId);
    if( Trim(objControl.value) == "")
    {
        document.getElementById(sControlBackId).style.display = "block";
        objControl.style.display = "none";
    }    
    
}

function CheckDateChar(eObj)
{
    var oKey;
    
	if( navigator.userAgent.toLowerCase().indexOf("msie") != -1 )
	{ 
		oKey = eObj.keyCode;
	}
	else if( navigator.product == "Gecko" )
	{
		oKey = eObj.which;
	}
	
	if(oKey == 0 || oKey == 8)
	{
		return true;
	}
	return false;
    
}

//AJAX Function.
function _SetSelectedCountry(sClientId , sComboName , sName)
{
    if( document.getElementById( sClientId + sComboName ).value != "" )
    {
        document.getElementById( sClientId + sComboName ).className = "tlog-popcombobx";
    }
    else
    {
        document.getElementById( sClientId + sComboName ).className = "tlog-combobx";
    }
    
    var sQuery = "&mode=remote&combo="+sName+"&country=" + document.getElementById( sClientId + sComboName ).value;
    var url = document.getElementById( sClientId + "_hidXMLHttpPath" ).value ;
        
    var oXmlHttp_New;
	oXmlHttp_New = new ActlXmlHttp();
		
	//pass the name of the event handler in the property below or pass the call back event handler in the tagname "ACTLXMLEventHandler"
	oXmlHttp_New.ReadyStateChangeEventHandler = "fnReadyStateEventHandler";
	oXmlHttp_New.SendRequest(url, sQuery, "GET");
}

function fnReadyStateEventHandler(oXML, strError)
{
    var sClientId = String( oXML.responseXML.getElementsByTagName('cid')[0].firstChild.xml );
	document.getElementById( sClientId + "_autoWeddingCityState" ).value = "";
}


/////////////////////////////////////////////////////////////////////
//JS functions for Template Selection page.
/////////////////////////////////////////////////////////////////////

function fnView( sUrl, sTemplate)
{
    document.getElementById('imgFullView').src =   sUrl + sTemplate + ".gif" ;
    document.getElementById('lblThemeName').innerHTML = sTemplate; 
}

function fnShowTemplate(url,queryStr)
{   
    ShowLoadDiv();
    fnSendRequest(url,queryStr); 
    return false;
}

function ShowLoadDiv()
{
    var objDiv = document.getElementById("divLoad");
    objDiv.style.display = "block";
    objDiv.style.left = screen.width/2;
    //objDiv.style.top = screen.height/2;
    
    var ttop =  parseInt(fnGetOffsetTop(document.getElementById('CenterDiv')),10) +  parseInt(document.getElementById('CenterDiv').offsetHeight)/2; 
    objDiv.style.top = ttop ;
}

//Fucnction will be called for the first time to display selected item.
function fnSetBorderofFirst( tblClientId )
{
    tblClient = document.getElementById(tblClientId);
    tblClient.setAttribute("isclick","1");
    
    if(tblClient .fireEvent)
    {
        tblClient.fireEvent("onmouseover");
    }
    else
    {
        var evtObj = document.createEvent('MouseEvents');
        evtObj.initMouseEvent( "mouseover", true, true, document.defaultView, 1, 0, 0, 0, 0, false, false, true, false, 0, null);
        tblClient.dispatchEvent( evtObj );
    }
    document.getElementById('hdnLastTemplateSelected').value = tblClientId;
   
}

//On MouseClick function.
function fnChangeCss(objImage)
{
    var objselId = document.getElementById('hdnLastTemplateSelected')
    
    var objPrevSelId = document.getElementById( objselId.value );
    objPrevSelId.setAttribute("isclick" , "0");
    
    //Remove selected border from previous selected item.
    fnsetBorder( objPrevSelId );
    
    objselId.value = objImage.id; 
    objImage.setAttribute("isclick" , "1");
    
    //Set maroon border color to the selected item.
    fngetBorder(objImage);
}

//On Mouseover class.
function fngetBorder(objImage)
{
//    if(document.getElementById('hdnLastTemplateSelected').text != 'undifine');
//    { 
//        var otbl=document.getElementById('hdnLastTemplateSelected');
//        otbl.className="";
//    }

    //yellow border color class. Apply to the table when mouse over on it.
    var sClass = "tpsl-thb-over";
    var sSecClass = "tpsl-thb-txt-over";
    
    //If current table is a selected item then appply marron border color.
    if( document.getElementById('hdnLastTemplateSelected').value == "" || objImage.getAttribute("isclick") == "1")
    {
        sClass = "tpsl-thb-act";
        sSecClass = "tpsl-thb-txt-act";
    }
    
    objImage.rows[0].cells[0].className = sClass;
    for( i=0 ; i<objImage.rows[0].cells[0].childNodes.length ; i++ )
    {
        if( String(objImage.rows[0].cells[0].childNodes[i].tagName ).toLowerCase() == "table" )
        {   
            objSubTable = objImage.rows[0].cells[0].childNodes[i] 
            objSubTable.rows[0].cells[0].className = sSecClass;
        }
    }
}

//On mouseout class.
function fnsetBorder(objImage)
{
    if( objImage.getAttribute("isclick") != "1" )
    {
        objImage.rows[0].cells[0].className = "tpsl-thb-dis";
        for(i=0 ; i<objImage.rows[0].cells[0].childNodes.length ; i++ )
        {
            if( String(objImage.rows[0].cells[0].childNodes[i].tagName ).toLowerCase() == "table" )
            {
                objSubTable = objImage.rows[0].cells[0].childNodes[i] 
                objSubTable.rows[0].cells[0].className = "tpsl-thb-txt-dis";
            }
        }   
    }
}

// RemoteCall Request.
function fnSendRequest(url, queryStr)
{
    var oXmlHttp_New;
    oXmlHttp_New = new ActlXmlHttp();
    oXmlHttp_New.ReadyStateChangeEventHandler = "SetResult";
    oXmlHttp_New.SendRequest(url, queryStr, "GET");
    return false;
}

//Select Template - Do postback
function DesfnSelectTemplate(objLink , url , sTempName )
{
   if( objLink.getAttribute("SkinSrc") != "" )
   {
       if( sTempName != '')
       {
            if(! confirm('Your current design is "'+ sTempName +'". Would you like to update your wedsite\'s design to "'+ document.getElementById('lblThemeName').innerHTML + '"?') )
            {
                return false;
            }        
       }
   
       var oForm = document.getElementById("Form");
       oForm.action = url+'&IsSelect=true&Id='+document.getElementById('hdnSelectedTemplateId').Value;
       oForm.submit();
   }
   return false;
}

function fnSelectTemplate(objLink , url)
{
   if( objLink.getAttribute("SkinSrc") != "" )
   {
       var oForm = document.getElementById("Form");
       oForm.action = url+'&IsSelect=true&Id='+document.getElementById('hdnSelectedTemplateId').Value;
       oForm.submit();
   }
   return false;
}

//Function handles AJAX request.
function SetResult(oXML, strError)
{     
    if(strError == null)
    { 
        document.getElementById("divLoad").style.display = "none";
        if( GetBrowserInfo() == "IE" )
        {   
            var sTemplateID = oXML.responseXML.getElementsByTagName('TemplateID')[0].firstChild.xml;
            //As Template description becomes non mandatory field. So add the null condition.
            var sTemplateDescription = "";
            if (oXML.responseXML.getElementsByTagName('TemplateDescription')[0].firstChild != null)
            {
                sTemplateDescription = oXML.responseXML.getElementsByTagName('TemplateDescription')[0].firstChild.xml;
            }
            var clientId = oXML.responseXML.getElementsByTagName('clientId')[0].firstChild.xml;
        
            if (oXML.responseXML.getElementsByTagName('SkinSrc')[0].firstChild != null)
            {
                var sSkinSrc = oXML.responseXML.getElementsByTagName('SkinSrc')[0].firstChild.xml;
            }
        
            document.getElementById('hdnSelectedTemplateId').Value=sTemplateID;
            document.getElementById(clientId+ '_lblTemplateDescription').innerHTML=sTemplateDescription;
        
            var objLink      = document.getElementById( clientId+ '_lnkSelect' );
            var objLink1    = document.getElementById( clientId+ '_lnkSelect1' );
            
            if(sSkinSrc == undefined)
            {
	            objLink.setAttribute("SkinSrc" , "");
	            objLink1.setAttribute("SkinSrc" , "");
	            objLink.className = "tpsl-seldesign-dis";
                objLink1.className = "tpsl-seldesign-dis";
            }
            else
            {               
                objLink.setAttribute("SkinSrc" , sSkinSrc);
                objLink1.setAttribute("SkinSrc" , sSkinSrc);
                objLink.className = "tpsl-seldesign";
                objLink1.className = "tpsl-seldesign";
            }
             
            document.getElementById(clientId + "_lnkViewSite").setAttribute("template" , oXML.responseXML.getElementsByTagName('TemplateName')[0].firstChild.xml );
         }
         
         else
         {
            var sTemplateID = oXML.responseXML.getElementsByTagName('TemplateID')[0].textContent;
            var sTemplateDescription = oXML.responseXML.getElementsByTagName('TemplateDescription')[0].textContent;
            var clientId = oXML.responseXML.getElementsByTagName('clientId')[0].textContent;
            
            var sSkinSrc;
            if (oXML.responseXML.getElementsByTagName('SkinSrc')[0]!= null)
            {
                sSkinSrc = oXML.responseXML.getElementsByTagName('SkinSrc')[0].textContent;
            }
        
            document.getElementById('hdnSelectedTemplateId').Value  =   sTemplateID;
            document.getElementById(clientId+ '_lblTemplateDescription').innerHTML  =   sTemplateDescription;
            
            var objLink     = document.getElementById( clientId+ '_lnkSelect' );
            var objLink1    = document.getElementById( clientId+ '_lnkSelect1' );
            
            if( sSkinSrc == "" )
            {
	            objLink.setAttribute("SkinSrc" , "");
	            objLink1.setAttribute("SkinSrc" , "");
	            objLink.className = "tpsl-seldesign-dis";
                objLink1.className = "tpsl-seldesign-dis";
            }
            else
            {               
                objLink.setAttribute("SkinSrc" , sSkinSrc);
                objLink1.setAttribute("SkinSrc" , sSkinSrc);
                objLink.className = "tpsl-seldesign";
                objLink1.className = "tpsl-seldesign";
            }
        
            document.getElementById(clientId + "_lnkViewSite").setAttribute("template" , oXML.responseXML.getElementsByTagName('TemplateName')[0].textContent );             
         }     
    }
    else
    {
	    alert("Error in XML : " + strError );
    }	    
     
    return false;     
}

function fnViewSite( objView , sUrl )
{
    
    sTemplate = objView.getAttribute( "template" ) + "/default.htm";
    var strURL = sUrl + sTemplate ;
  
    window.open( strURL , "ViewSite" );
    return false;
}

function fnChagneTemplateConf( sTempName )
{
    if( confirm('Your current design is "'+ sTempName +'". Would you like to update your wedsite\'s design to random design?') )
    {
        return true;
    }    
    return false;
}

////////////////////////////////////////////////////////////////
//  MUSIC SELECTION PAGE JS FUNCTIONS
////////////////////////////////////////////////////////////////

function fnCheckYear(sclientid)
{
    if(parseInt(document.getElementById(sclientid+'_txtYear').value.length) > 0)
    {
		var oRegExp = new RegExp("^[0-9\\s]*$", "gi");
		
		if(oRegExp.test(String(document.getElementById(sclientid+'_txtYear').value)))
		{
		    document.getElementById('serrormessage').innerHTML="";		
		    return true;
		}
		else
		{
            //document.getElementById('serrormessage').innerHTML="";		
            //document.getElementById(sclientid+'_txtYear').focus();
		    return false;   
		}
	}
}

function fnAddTune(sclientid , oLink )
{
    document.getElementById(sclientid+'_txtMusicName').value="";
    document.getElementById(sclientid+'_txtArtistName').value="";
    document.getElementById(sclientid+'_txtAlbumName').value="";
    document.getElementById(sclientid+'_txtYear').value="";
    document.getElementById(sclientid+'_flUploadMusic').outerHTML=document.getElementById(sclientid+'_flUploadMusic').outerHTML;
    document.getElementById('serrormessage').innerHTML="";
    var oDiv = document.getElementById( "divUpload" );
    oDiv.style.display = "block";
    
    oDiv.style.top = fnGetOffsetTopScreen( oDiv , oLink);
    oDiv.style.left = fnGetOffsetLeftScreen( oDiv );
    
    document.getElementById(sclientid+'_txtMusicName').focus();
    return false;
}

function fnGetOffsetTopScreen (oDiv , oLink)
{   
    return fnGetOffsetTop(oLink) -  255;
    
//    alert( (parseInt( window.screen.availHeight )/2) +  ( (parseInt( window.screen.availHeight )/2) - 245 ) );
//    return (parseInt( window.screen.availHeight )/2) +  ( (parseInt( window.screen.availHeight )/2) - 245 ) - parseInt(document.body.scrollTop) - 30;
//    return parseInt( window.screen.availHeight )- 270 - parseInt(document.body.scrollTop) ;
//    odvInnerMessage.style.top = (parseInt(window.screen.height)/2) - (parseInt(odvInnerMessage.style.height)/2) + parseInt(document.body.scrollTop)

//    return fnGetOffsetTop(event.srcElement) - 245 ;
//    return (parseInt(window.screen.height)/2) + ( (parseInt(window.screen.height)/2) - 200 );
//    //return ( parseInt(document.body.scrollTop) + (parseInt(window.screen.height)/2) - 245);
//    
//    return screen.height - 300 - window.screenTop;
//    return event.screenY - 300;
//    return ( screen.height - (oDiv.offsetHeight * 2)) + 100;
}
function fnGetOffsetLeftScreen (oDiv)
{
    //return ((screen.width - (oDiv.offsetWidth * 2))- 250 );// Div width 
    return 18;
}

function fnGetOffsetTop (oEl)
{
	var iTop = oEl.offsetTop;
	while((oEl = oEl.offsetParent) != null)
	{	iTop += oEl.offsetTop;		}
       // alert("Parent: " + iTop)
	return iTop;
}

function fnGetOffsetLeft (oEl)
{
	var iLeft = oEl.offsetLeft;
	while ((oEl = oEl.offsetParent) != null)
		{	iLeft += oEl.offsetLeft;		}
       // alert("Parent: " + iTop)
	return iLeft;
}
function fnPlayNow(flpath,flname,flExt)
{
    if(flExt == "True")
    {
        document.getElementById("spanPlayMusic").innerHTML = "<embed src='"+flpath+"Yaadein/Musics/"+flname+"' style='display:none'></embed>";
    }
    else
    {
        alert("Music can't play.Music file may not exists");
    }
    return false;       
}

//////////////////////////////////////////////////////////////
//Function will be used to open music window contains music
//flash file.
//////////////////////////////////////////////////////////////
function OpenWindow(url,Musicid)
{
    url = url + "/MusicPlayer.aspx?MusicID=" + Musicid;
    var WindowParameters = "left=" + (window.screen.width / 3) + ",top="+window.screen.height / 3+",width=290,height=320";
	    
	 window.open(url,"WeddingMusic",WindowParameters);
	 return false;
}

function fnStopMusic()
{
    document.getElementById("spanPlayMusic").innerHTML = "";
}


function fnUploadMusic()
{
    document.getElementById("divUploadMusic").style.display = 'block';
}

function fnShow(sClientId)
{
//    var oDiv = document.getElementById( "divUpload" );
//    oDiv.style.display = "block";
//    oDiv.style.left = fnGetOffsetLeft( event.srcElement );
//    oDiv.style.top = fnGetOffsetTop( event.srcElement ) + 20;
}

function fnValidateMusicFile(clientid)
{
    if(parseInt(document.getElementById(clientid+"_flUploadMusic").value.length) > 0)
    {
        var sPath = document.getElementById(clientid+'_flUploadMusic').value;
        var iInd;
        var sExt;
        iInd = sPath.lastIndexOf("\\");
        if(parseInt(iInd) > 0)
        {
	        if(iInd != -1)
	        {
		        sPath = sPath.substring(iInd + 1);
		        sExt=sPath;
		        sExt= sExt.substring(sExt.lastIndexOf(".")+1);
		        //if(sExt.toLowerCase() == 'mp3' || sExt.toLowerCase() == 'wav' || sExt.toLowerCase() == 'avi' )
		        if(sExt.toLowerCase() == 'mp3' )
		        {
			        if((parseInt(sPath.length)-4) > 128)
    		        {
	    	            document.getElementById('serrormessage').innerHTML="<br>Invalid file name!";
		                return false;
		            }
		            else
		            {
		                document.getElementById('serrormessage').innerHTML="";
		                return true;
		            }
                }
                else
                {
                    document.getElementById('serrormessage').innerHTML= "This file type cannot be accepted.";
                }			            
	        }
        }
        else
        {
            document.getElementById('serrormessage').innerHTML= "<br> invalid file path!";
        }
        return false;
    }
    else
    {
        document.getElementById('serrormessage').innerHTML="";//document.getElementById('serrormessage').innerHTML + "<br>"+ "Please select file to upload.";
        if(parseInt(document.getElementById(clientid+'_txtMusicName').value.length) < 1)
        {
            document.getElementById(clientid+'_txtMusicName').focus();
        }
        else
        {
        
            document.getElementById(clientid+'_flUploadMusic').focus();
        }
        return false;
    }
}
function fnCancelUpload()
{
     document.getElementById("divUpload").style.display = "none";
}
// End Music Selection 


var userAgent = navigator.userAgent.toLowerCase();
function fnAllowOnly(oElement, oEventObject, oArrChars, blnDisallowCharacters)
	{
		var blnReturnValue;
		var strNullExceptionMessage = "The oElement is null";
		var strInsertingText, strNewInsertingText;
		var intControlTextLength, intSelectionLength, intClipBoardTextLength, intExcessChars;
		var oSelectionRange, intWhich=1;
		try
		{
			if(oEventObject!=null)
			{
			
				switch(oEventObject.type.toLowerCase())
				{
					case 'keypress':
					
                        //fnCheckLength( oElement, piMaxLength ,ErrorMsg)
					    if(!(GetBrowserInfo() == "IE"))
					    {
						    intWhich = oEventObject.which;
						    ///-- For backspace keycode. Had to hard code for it.!
						    if(intWhich==8)
							    intWhich = 0;
					    }
					    if(intWhich!=0)
					    {
						    blnReturnValue = this.fnIsSrcStrCharacterFromCharSet(oArrChars, String.fromCharCode(this.fnGetKeyCode(oEventObject)), !blnDisallowCharacters);
                        }    
					    else
					    {
						    blnReturnValue = true;
                        }
					break;
					case 'paste':
					    fnCheckPasteLength( oElement, piMaxLength ,ErrorMsg)
						strInsertingText = window.clipboardData.getData('text');
						blnReturnValue = this.fnIsSrcStrCharacterFromCharSet(oArrChars, strInsertingText, !blnDisallowCharacters);
					break;
					
					default:
						if(oElement!=null)
						{
							blnReturnValue = this.fnIsSrcStrCharacterFromCharSet(oArrChars, oElement.value);
                        }
						//else
						//{
							//this.fnThrowACTLError(strNullExceptionMessage);
						//}
					break;
				}
			}
			else
			{
				if(oElement!=null)
					blnReturnValue = this.fnIsSrcStrCharacterFromCharSet(oArrChars, oElement.value);
				//else
					//this.fnThrowACTLError(strNullExceptionMessage);
			}
			//if(!blnReturnValue)
			//	this.fnCancelEvent(oEventObject);
		}
		catch(oException)
		{
			
		}
		return blnReturnValue;
	}
	function fnGetKeyCode(oEventObject)
	{
		try
		{ 
		    if(GetBrowserInfo() == "IE")
		    {
                return oEventObject.keyCode;
            }
            else
            {
                return oEventObject.which;
            }
		}
		catch(oException)
		{
		
		}
	}
	function fnIsSrcStrCharacterFromCharSet(oArrChars, strSourceString, blnCheckUnion)
	{
		var blnIsInCharSet;
		var blnReturnValue = true;

		try
		{
			for(var a=0;a<strSourceString.length;a++)
			{
				blnIsInCharSet = false;
				for(var b=0;b<oArrChars.length;b++)
				{
					if(String(strSourceString.charAt(a)) == String(oArrChars[b]))
					{
						blnIsInCharSet = true;
						break;
					}
				}
				if(blnIsInCharSet!=blnCheckUnion)
					blnReturnValue = false;
			}
		}
		catch(oException)
		{
		}
		return blnReturnValue;
	}
	function GetBrowserInfo()
    {
        if(eval( userAgent.indexOf('msie') != -1 ))
        {
	        return "IE";
        }
        else if( eval(navigator.product == 'Gecko') )
        {
	        return "FF";
        }
    }
	function fnObjectInitializer(strClassName, strOnNullExceptionMessage, oArrVariableArguments)
	{
	
		try
		{
			///-- 1. Declaring variables
			var objUserObject;
			var intArgCounter, strActualArguemnts="";
			var strNullErrorMessage = "The object initialization failed." ///$$ Hardcoding default Null Exception message
			
			///-- 2. Initializing variables
			if(strOnNullExceptionMessage!= '' && strOnNullExceptionMessage!=null && typeof strOnNullExceptionMessage!='undefined')
				strNullErrorMessage = strOnNullExceptionMessage;

			///-- 3. Building Arguments string for eval
			if(typeof (oArrVariableArguments)=='undefined')
				oArrVariableArguments = new Array();
			for(var intArgCounter=0;intArgCounter<oArrVariableArguments.length;intArgCounter++)
			{
				strActualArguemnts += "," + ("oArrVariableArguments[" + intArgCounter + "]");
			}
			if(strActualArguemnts!='')
				strActualArguemnts = strActualArguemnts.substr(1);

			///-- 4. Creating object, returning if all OK, else throwing exception.
			objUserObject = eval("new " + strClassName + "(" + strActualArguemnts + ")");

			return objUserObject;
		}
		catch(oException)
		{
			
		}
	}
	
	