﻿// JScript File

    // verifies only a number was typed into the form element
    function numbersonly(e){
        var unicode=e.charCode? e.charCode : e.keyCode
        // if (unicode!=8||unicode!=9)
        if (unicode<8||unicode>9)
            {
            //if the key isn't the backspace key or tab key (which we should allow)
            if (unicode<48||unicode>57) //if not a number
            return false //disable key press
        }
    }

    function GetURLParams(name)
    {
      name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
      var regexS = "[\\?&]"+name+"=([^&#]*)";
      var regex = new RegExp( regexS );
      var results = regex.exec( window.location.href);
      if(results == null) 
         return "";  
         else    
         return results[1];
    }
    
    
function GetDomainName()
{
    var url = window.location;
      var urlparts = url.href.split('//');
      var DomainName = urlparts[1].split('/');
      return DomainName[0];
}

 function loadjscssfile(filename, filetype)
 {
     if (filetype=="js"){ //if filename is a external JavaScript file
      var fileref=document.createElement('script')
      fileref.setAttribute("type","text/javascript")
      fileref.setAttribute("src", filename)
     }
     else if (filetype=="css"){ //if filename is an external CSS file
      var fileref=document.createElement("link")
      fileref.setAttribute("rel", "stylesheet")
      fileref.setAttribute("type", "text/css")
      fileref.setAttribute("href", filename)
     }
    
     if (typeof fileref!="undefined")
      document.getElementsByTagName("head")[0].appendChild(fileref)
 }
 

   
    
 function getCustomUrl()
{
  var url = window.location;
  var urlparts = url.href.split('//');
  var DomainName = urlparts[1].split('/');
  return DomainName[0];
}


function ReplaceAllWith(strFromText,strText,strWith)
{
var intIndexOfMatchNext = strFromText.indexOf(strText);
// Loop over the string value replacing out each matching
while (intIndexOfMatchNext != -1)
{
    // Relace out the current instance.
    strFromText = strFromText.replace(strText,strWith)
    // Get the index of any next matching substring.
   intIndexOfMatchNext = strFromText.indexOf(strText);
}
//End of repacing of <br />
return strFromText;
}


function GetImageUniqueId(GalFocusImg)
{
var strGId = GalFocusImg.split('.')[0];   	  
strGId =  ReplaceAllWith(strGId,"_","");
return strGId;
}



/*****************************************Vamshi*****************************************/

var strSetSession ="";
var strPubDetails ="";

strSetSession = AjaxUtilsMethods.CheckAndAssignPubValues(window.location).value;//16oct2011


//******17May2010 here down we are checking if the call is from parent page(index.shtml.login,register etc.,) or from 
// child page (galleryview, imageview , viewgalleryclip etc., if it is from child we will assign path and pub id from session else from publications.config file)


try
{

            if (!window.opener)
            {

            strSetSession = AjaxUtilsMethods.CheckAndAssignPubValues(window.location).value;
            strPubDetails = AjaxUtilsMethods.GetPublicationDetails().value.split('_');

            }
            else
            {

            // here we are checking for ddleditions combo whether it is in opener or opener.opener if not found in both we assign pub details from publications.config


                if (window.opener.document.getElementById("ddlEditions") != null) // checking in opener (used in galleryview.shtml,imageview.shtml)
                {
                strPubDetails = window.opener.document.getElementById('ddlEditions').value.split('_');
                }
                else
                {
                    if(!window.opener.opener) // for feedback.htm ,forgotpassword.shtml 
                    {
                     strSetSession = AjaxUtilsMethods.CheckAndAssignPubValues(window.location).value;
                     strPubDetails = AjaxUtilsMethods.GetPublicationDetails().value.split('_');
                    }
                    else
                    {
                     strPubDetails = window.opener.opener.document.getElementById('ddlEditions').value.split('_');//checking in opener.opener(used in viewclippings.htm,sendmail.htm)
                    }
                }
            }
}
catch(err)//if any exception occurs we are assigning default values
{
                     strSetSession = AjaxUtilsMethods.CheckAndAssignPubValues(window.location).value;
                     strPubDetails = AjaxUtilsMethods.GetPublicationDetails().value.split('_');

}

var strPublicationID=strPubDetails[0];
var Pub_RootPath  = strPubDetails[1];

var urlCheck = window.location.href;

if ( urlCheck.indexOf("ArticleHtmls") <= 0 )
{
document.title=":: " + AjaxUtilsMethods.GetPublicationName().value+ " ePaper ::";
}
//******end 17May2010*************************************************************************//

 var arrPropConfig = AjaxUtilsMethods.GetPropConfigSettingsAll().value.split("$@$"); 
 arrPropConfig.unshift("DumpyFirstValue");//adding dumpy first value so that the value we pass will match with the property.config


//var  SITEURL =  getCustomUrl();
//AjaxUtilsMethods.setSession("strDomain",SITEURL);

//var x =AjaxUtilsMethods.getSession("strDomain").value;


// Pub_RootPath = Pub_RootPath.replace('/',''); added vamshi 04 Jan 09

var cssPath=arrPropConfig[81];
//var Pub_RootPath = AjaxUtilsMethods.GetRootpath(getCustomUrl()).value;

var strLayoutType = arrPropConfig[93] ; //AjaxUtilsMethods.GetPropertyConfigSettingsNew('87',getCustomUrl()).value;



/*****************************************Vamshi*****************************************/

function openRSSFeed1(strCat)
{
open(VirtualPath+"/"+"RSSFeed.aspx?Category="+strCat); 
}


function openRSSFeed(strCat) {   

    open(VirtualPath + "/" + "RSSFeed.aspx?Category=" + strCat + "&EdId=" + strPublicationID); 
}


  function AssignText(id,text)
    {
       document.getElementById(id).innerHTML = text;
    }




loadjscssfile("../../../../../../"+arrPropConfig[104], "js") ;


    function GetURLStyle()
 	{
 	    var logo_url = AjaxUtilsMethods.GetLogoUrl().value;
 	    var logo_urls = logo_url.split(","); 
 	    if(logo_urls[0] == '1')
 	    {
            document.getElementById("logourlImage").style.cursor="pointer";
             
 	    }
	}
	
	function GetURL()
 	{
 	    var logo_url = AjaxUtilsMethods.GetLogoUrl().value;
 	    var logo_urls = logo_url.split(","); 
 	    if(logo_urls[0] == '1')
 	    {
            window.open(logo_urls[1],'_blank'); 	
 	    }
 	}
 	
 	function TakeATour()
 	{
 	fadeoutclose();
 	window.open('../../../Tour/indexHelp.htm','','left=100,top=100,width=775,height=500');
 	}
 	
 	function GetRegistration()
   {
	 window.location.href =arrPropConfig[110];
   }




/************14Sept2010**********moved from js/indexpage.js and jsfor2page/indexpage.js***************************************/

function GetLatestDate() {
    var winURL = window.location.href;
    var dateurls = winURL.split('/');

    if (dateurls.length > 8) {
        selectedDate = dateurls[dateurls.length - 4] + '/' + dateurls[dateurls.length - 3] + '/' + dateurls[dateurls.length - 2];
    }
    else {
        var response = AjaxUtilsMethods.getCurrentDate();
        if (response.value != null) {
            selectedDate = response.value;
        }
    }
}

GetLatestDate();
/*************14Sept2010********moved from js/indexpage.js and jsfor2page/indexpage.js***************************************/

function IsDateExistsInDidXml(array, obj) {

    
    obj = obj.split("/");
    var selDate = obj[1] + "/" + obj[2] + "/" + obj[0]
    
    var i = array.length;
    while (i--) {
        if (array[i].split("_")[0] == selDate) {
            return true;
        }
    }
    return false;
}
/*************14Sept2010*****************************/



