loc1 = window.location+"";
//alert(loc1);
if(loc1.indexOf('header.aspx') == -1)
{
	setPageName();
}
function setPageName() 
{
	//debugger;
	//var loc1;
	loc1 = window.location+"";
	//alert(loc1.substring(loc1.indexOf('pages')));
	UType = readCookie('UserType');
	//UType = "CA";
	//alert(UType);
	strLocation = loc1.substring(loc1.indexOf('pages'));
	if(UType == "CA")
		createCookie('strLocation',strLocation,1)
	else
		createCookie('strLocationSA',strLocation,1)
	//alert(loc1);
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
			window.open(theURL,winName,features);
		}


function formatStr(EL,maxchars)
// the EL is the target element passed fron the invokin process in the form:
// maxchars is no of characters per line or the nth character at which text to be wrapped. For Ex At 15th character//
// document.getElementById('idofelement');
{
   //strbuff=EL.innerHTML;
   strbuff=EL;
// takes the content of the eleemtn and puts it into a string
   newstr='';
   startI = 0;
   max=maxchars;
   str='';
   subarr=new Array(parseInt(strbuff.length/max+1));
// creates an array with a length that will hold all max character segments + the final bit.
// in the earlier versio I was using 7 which is incorrect 15 is the required size
   for (i=0;i<subarr.length;i++)
   {
      // this loop creates max character substrings an put them in anarray 
      subarr[i]=strbuff.substr(startI,max);
      startI+=max;
   }
   for (i=0;i<subarr.length;i++)
   {
      // this loop creates a new string by concatenating the elements in the array
      // with an HTML line break tag between each segment
      newstr+=subarr[i]+'<br />';
   }
   str+=subarr[subarr.length-1];
     // the final segement is append outside to loop to avoid an extra linefeed
   //EL.innerHTML=newstr;
   return newstr;
    // the content of the target element is replaced with the new string
}

function ExtendedToolTipText(vals)
{
	if(vals.indexOf(' ')<=-1)
	{
		if(vals.length<90)
			vals1=formatStr(trim(vals),vals.length);
		else
			vals1=formatStr(trim(vals),90);
	}
	else
		vals1=trim(vals);
	var divtext = "<table cellSpacing=0 cellPadding=0 width=100%><tr><td class=second_row><table cellSpacing=1 cellPadding=0 width=100% bgColor=#2f3235>";
	divtext = divtext + "<tr><td bgColor=#ffffff><table class=normal_text cellSpacing=1 cellPadding=5 width=100%><tr><td class=normal_text>" + vals1 + "</td></tr>";
	divtext = divtext + "</table></td></tr></table></td></tr></table>";
	return divtext;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
// PURPOSE: To Clear the Message.
function clearLabel(lblName)
{
	document.getElementById(lblName).innerHTML = "";
}
function CheckBoxConfirm(CheckBoxObjects, ConfirmationMessage, WarningMessage){		
	if(CheckBoxObjects.length != undefined)	{
		for(i=0;i< CheckBoxObjects.length; i++)
		{
			if(CheckBoxObjects[i].checked){	
				return confirm(ConfirmationMessage);
			}
		}
	}else{
		if(CheckBoxObjects.checked){	
			return confirm(ConfirmationMessage);
		}
	}
	alert(WarningMessage);
	return false;
}
// PURPOSE: To search on Enter button Click.
function clickButton(e, buttonid){
	  var bt = document.getElementById(buttonid); 
      if (typeof bt == 'object'){ 
            if(navigator.appName.indexOf("Netscape")>(-1)){ 
                  if (e.keyCode == 13){ 
                        bt.click(); 
                        return false; 
                  } 
            } 
            if (navigator.appName.indexOf("Microsoft Internet Explorer")>(-1)){ 
                  if (event.keyCode == 13){ 
                        bt.click(); 
                        return false; 
                  } 
            } 
      } 
}

function ltrim(str)
/***
        PURPOSE: Remove leading blanks from string.
***/
{
        var whitespace = new String(" \t\n\r");
        var s = str; // new String(str);
        if (whitespace.indexOf(s.charAt(0)) != -1) {
            var j=0, i = s.length;
            while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
                j++;
            s = s.substring(j, i);
        }
        return s;
}

function rtrim(str)
/***
        PURPOSE: Remove trailing blanks from our string.
***/
{
        var whitespace = new String(" \t\n\r");
        var s = str; //new String(str);
        if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
            var i = s.length - 1;       // Get length of string
            while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
                i--;
            s = s.substring(0, i+1);
        }
        return s;
}

function trim(str)
/***
			PURPOSE: Remove trailing and leading blanks from our string.
***/
{
        return rtrim(ltrim(str));
}

//function to replace a string
function strReplace(s, r, w)
{
	return s.split(r).join(w);
}
//function to check invalid characters in text box
function chkinvalidchar(x)
{
	nname=x.name;
	fname=trim(x.value);
	if((fname.indexOf(">")!=-1)||(fname.indexOf("<")!=-1))
	{
		return false;
	}
	return true;
	/*nname=x.name;
	fname=trim(x.value);
	//fname=strReplace(fname,"  "," ");
	//regname=/^[a-zA-Z0-9\s\-\'']+(([-][a-zA-Z\s\-\''])?[a-zA-Z\s\-\'']*)*$/
	//regname=/[0-9a-z A-Z\s\-\'']+<[^>]*>/;
	//alert(fname);
	//regname=/^([a-zA-Z0-9\s\-\'']+)/
	regname = /^[a-zA-Z0-9]+(([\n\r\'\"\,\.\-\ \][a-zA-Z0-9])?[a-zA-Z0-9]*)*$/
	/*fnameflag=fname.match(regname);	
	alert(fnameflag);
	if (fnameflag != fname)
	{		
		x.focus();
		x.select();	
		return false;
	}*/
	/*
	fnameflag=fname.search(regname);
	//alert(fnameflag);
	
	if (fnameflag == -1)
	{		
		x.focus();
		x.select();	
		return false;
	}
	return true;*/
}

//function to check the pricing validation
function chkpricing(objPrice, decChar)
{
	/*if(isNaN(objPrice.value))
	{
		objPrice.focus();
		objPrice.select();
		return false;
	}*/	
	decChar = "\\" + decChar;
	
	//strRegExp = "^[-]?([1-9]{1}[0-9]{0,}(" + decChar + "[0-9]{0,2})?|0(" + decChar + "[0-9]{0,2})?|" + decChar + "[0-9]{1,2})$";
	strRegExp = "^([1-9]{1}[0-9]{0,}(" + decChar + "[0-9]{0,2})?|0(" + decChar + "[0-9]{0,2})?|" + decChar + "[0-9]{1,2})$";

	regPrice = new RegExp(strRegExp);

	fpricingflag = objPrice.value.search(regPrice);

	if(fpricingflag == -1)
	{
		//alert("Invalid Price. Please only numbers and decimals");
		objPrice.focus();
		objPrice.select();
		return false;
	}
	return true;
}
//function to check url validation
function chkurl(x)
{
	/*
	fmail=x.value;
	regmail=/http:[a-zA-Z0-9_\-\. \/]+\.[a-zA-Z0-9\&\?\-\=\.]+/
	fmailflag=fmail.match(regmail);
	regmail1=/https:[a-zA-Z0-9_\-\. \/]+\.[a-zA-Z0-9\&\?\-\=\.]+/
	fmailflag1=fmail.match(regmail1);
	if ((fmailflag!=fmail)&&(fmailflag1!=fmail))
	{
		return false;
	}
	return true;
	*/
	if (!isURL(x.value))
	{
		return false;
	}
	return true
}
function isURL (url)
{
	//var urlPattern = /^(?:(?:ftp|https?):\/\/)?(?:[a-z0-9](?:[-a-z0-9]*[a-z0-9])?\.)+(?:com|edu|biz|org|gov|int|info|mil|net|name|museum|coop|aero|[a-z][a-z])\b(?:\d+)?(?:\/[^;"'<>()\[\]{}\s\x7f-\xff]*(?:[.,?]+[^;"'<>()\[\]{}\s\x7f-\xff]+)*)?/;
	//var urlPattern = /^(?:(?:https?):\/\/)?(?:[a-z0-9](?:[-a-z0-9_]*[a-z0-9])?\.)+(?:com|edu|biz|org|gov|int|info|mil|net|name|museum|coop|aero|[a-z][a-z])\b(?:\d+)?(?:\/[^;"'<>()\[\]{}\s\x7f-\xff]*(?:[.,?]+[^;"'<>()\[\]{}\s\x7f-\xff]+)*)?/;
	var urlPattern=/(http|https):[a-zA-Z0-9_\-\. \/]+\.[a-zA-Z0-9\&\?\-\=\.]+/
	return urlPattern.test(url.toLowerCase());
}

// function checks and removes and adds values to the invisible box
function CheckValue(val,holder)
{
	name=val;
	organvalue=document.getElementById(holder).value;
	name1=","+name+",";
	s=organvalue.indexOf(name1);
	if(s==-1)
	{
		organvalue+=name+",";
	}
	else
	{
		organvalue=strReplace(organvalue,','+name+',',",");
	}
	document.getElementById(holder).value=organvalue;
	return false;
}
// function checks and removes and adds values to the invisible box
function getCheck(name,chkboxname,txtboxname,holder)
{
	ids=strReplace(name,chkboxname,txtboxname)
	name=document.getElementById(ids).value;
	organvalue=document.getElementById(holder).value;
	name1=","+name+",";
	s=organvalue.indexOf(name1);
	if(s==-1)
	{
		organvalue+=name+",";
	}
	else
	{
		organvalue=strReplace(organvalue,','+name+',',",");
	}
	document.getElementById(holder).value=organvalue;
	return false;
}
//function to ckeck the search box validation
function CheckSearch(txtSearchboxId)
{
	/*if(document.getElementById(txtSearchboxId).value=="")
	{
		alert(BLANK_SEARCH);
		return false;
	}*/
	var nm=document.getElementById(txtSearchboxId).value;
	if((nm.indexOf('>')!=-1)||(nm.indexOf('<')!=-1))
	{
		alert(INVALID_CHAR);
		document.getElementById(txtSearchboxId).focus();
		return false;
	}
}

//for active tabs
function fnShowpage(strMenu,otext,strPage,UserType)
	{
		document.getElementById("Header1_hdnUserType").value = UserType;
		UserTypeHidden = readCookie('UserType');
		if(strPage == "")
		{
			if(strMenu=="SetUp")
			{
				strPage = document.getElementById("Header1_hdnSetUpStartPageName").value;
			}
			if(strMenu=="ContentManagement")
			{
				strPage = document.getElementById("Header1_hdnContentUpStartPageName").value;
			}
		}
		
		initialSetupPageName = document.getElementById("Header1_hdnSetUpStartPageName").value;
		initialContentPageName = document.getElementById("Header1_hdnContentUpStartPageName").value;
		
		var objSpan;
		objSpan = document.getElementById(strMenu);
		
		switch(strMenu)
		{
			case 'Home':
				var fnname="\"fnShowpage('Home','"+otext+"','home.aspx',UserTypeHidden);setMenuValue('h');\"";
				objSpan.innerHTML = "<table cellspacing='0' cellpadding='0'><tr><td class='tab_active'><img src='image/open_activeTab.gif' width='2' height='27' class='img'></td><td class='tab_active'><img src='image/spacer.gif' width='13' height='2' class='img'><a href='#' class='link_tabactive' onclick="+fnname+">"+otext+"</a><img src='image/spacer.gif' width='13' height='2' class='img'></td><td><img src='image/close_activeTab.gif' width='5' height='27' class='img'></td></tr></table>";
				if(UserTypeHidden == "CA")
				{					
					createCookie('strMenu',strMenu,1)
				}
				else
				{
					createCookie('strMenuSA',strMenu,1)
				}
				parent.mainFrame.location = "PageRedirector.aspx?pageurl="+strPage;
				break;
			case 'SetUp':
				var fnname="\"fnShowpage('SetUp','"+otext+"','"+initialSetupPageName+"',UserTypeHidden);setMenuValue('s');\"";
				objSpan.innerHTML = "<table cellspacing='0' cellpadding='0'><tr><td class='tab_active'><img src='image/open_activeTab.gif' width='2' height='27' class='img'></td><td class='tab_active'><img src='image/spacer.gif' width='13' height='2' class='img'><a href='#' class='link_tabactive' onclick="+fnname+")>"+otext+"</a><img src='image/spacer.gif' width='13' height='2' class='img'></td><td><img src='image/close_activeTab.gif' width='5' height='27' class='img'></td></tr></table>";
				if(UserTypeHidden == "CA")
				{					
					createCookie('strMenu',strMenu,1);
				}
				else
				{
					createCookie('strMenuSA',strMenu,1)
				}
				parent.mainFrame.location = "PageRedirector.aspx?pageurl="+strPage;
				break;
			case 'ContentManagement':
				var fnname="\"fnShowpage('ContentManagement','"+otext+"','"+initialContentPageName+"',UserTypeHidden);setMenuValue('c');\"";
				objSpan.innerHTML = "<table cellspacing='0' cellpadding='0'><tr><td class='tab_active'><img src='image/open_activeTab.gif' width='2' height='27' class='img'></td><td class='tab_active'><img src='image/spacer.gif' width='13' height='2' class='img'><a href='#' class='link_tabactive' onclick="+fnname+">"+otext+"</a><img src='image/spacer.gif' width='13' height='2' class='img'></td><td><img src='image/close_activeTab.gif' width='5' height='27' class='img'></td></tr></table>";
				if(UserTypeHidden == "CA")
				{
					createCookie('strMenu',strMenu,1)
				}
				else
				{
					createCookie('strMenuSA',strMenu,1)
				}
				parent.mainFrame.location = "PageRedirector.aspx?pageurl="+strPage;
				break;	
			case 'Gallery':
				var fnname="\"fnShowpage('Gallery','"+otext+"','pages/gallery/ManageGallery.aspx',UserTypeHidden);setMenuValue('g');\"";
				objSpan.innerHTML = "<table cellspacing='0' cellpadding='0'><tr><td class='tab_active'><img src='image/open_activeTab.gif' width='2' height='27' class='img'></td><td class='tab_active'><img src='image/spacer.gif' width='13' height='2' class='img'><a href='#' class='link_tabactive' onclick="+fnname+">"+otext+"</a><img src='image/spacer.gif' width='13' height='2' class='img'></td><td><img src='image/close_activeTab.gif' width='5' height='27' class='img'></td></tr></table>";
				if(UserTypeHidden == "CA")
				{
					createCookie('strMenu',strMenu,1)
				}
				else
				{
					createCookie('strMenuSA',strMenu,1)
				}
				parent.mainFrame.location = "PageRedirector.aspx?pageurl="+strPage;
				break;
		}
		fnUnselectMenus(strMenu);
		return false;
	}

//for inactive tabs	
function fnUnselectMenus(strSelectedMenu)
	{
		var objSpan;
		if(strSelectedMenu != 'Home')
		{
			objSpan = document.getElementById('Home');
			var fnname="\""+objSpan.innerHTML.split("onclick=\"")[1].split("\"")[0]+"\"";
			objSpan.innerHTML = "<table cellspacing='0' cellpadding='0'><tr><td class='tab_inactive'><img src='image/spacer.gif' width='13' height='2' class='img'><a href='#' class='link_tabinactive' onclick="+fnname+">"+objSpan.innerText+"</a><img src='image/spacer.gif' width='13' height='2' class='img'></td></tr></table>";
		}
		
		if(strSelectedMenu != 'SetUp')
		{
			objSpan = document.getElementById('SetUp');
			var fnname="\""+objSpan.innerHTML.split("onclick=\"")[1].split("\"")[0]+"\"";
			objSpan.innerHTML = "<table cellspacing='0' cellpadding='0'><tr><td class='tab_inactive'><img src='image/spacer.gif' width='13' height='2' class='img'><a href='#' class='link_tabinactive' onclick="+fnname+">"+objSpan.innerText+"</a><img src='image/spacer.gif' width='13' height='2' class='img'></td></tr></table>";
		}
		if(strSelectedMenu != 'ContentManagement')
		{
			objSpan = document.getElementById('ContentManagement');
			var fnname="\""+objSpan.innerHTML.split("onclick=\"")[1].split("\"")[0]+"\"";
			objSpan.innerHTML = "<table cellspacing='0' cellpadding='0'><tr><td class='tab_inactive'><img src='image/spacer.gif' width='13' height='2' class='img'><a href='#' class='link_tabinactive' onclick="+fnname+">"+objSpan.innerText+"</a><img src='image/spacer.gif' width='13' height='2' class='img'></td></tr></table>";
		}
		if(strSelectedMenu != 'Gallery')
		{
			objSpan = document.getElementById('Gallery');
			var fnname="\""+objSpan.innerHTML.split("onclick=\"")[1].split("\"")[0]+"\"";
			objSpan.innerHTML = "<table cellspacing='0' cellpadding='0'><tr><td class='tab_inactive'><img src='image/spacer.gif' width='13' height='2' class='img'><a href='#' class='link_tabinactive' onclick="+fnname+">"+objSpan.innerText+"</a><img src='image/spacer.gif' width='13' height='2' class='img'></td></tr></table>";
		}
	}

//for active tabs
function fnShowpageColor(strMenu)
	{
		var objSpan;
		objSpan = document.getElementById(strMenu);
		switch(strMenu)
		{
			case 'Exterior':
				objSpan.innerHTML = "<table cellspacing='0' cellpadding='0'><tr><td class='pop_active_tab'><img src='image/spacer.gif' width='13' height='2' class='img'><a href='#' class='link_pop_tab_active' onclick=fnShowpageColor('Exterior')><b>Exterior</b></a><img src='image/spacer.gif' width='13' height='2' class='img'></td></tr></table>";
				createCookie('strMenu',strMenu,1)
				//parent.mainFrame.innerFrame.location = "../../PageRedirector.aspx?pageurl=pages/content/SwatchExteriorInner.aspx";//"../../PageRedirector.aspx?pageurl=pages/gallery/AllocateExteriorPhotos.aspx";
				document.getElementById("txtTabType").innerText = "Exterior";
				
				break;
			case 'Interior':
				objSpan.innerHTML = "<table cellspacing='0' cellpadding='0'><tr><td class='pop_active_tab'><img src='image/spacer.gif' width='13' height='2' class='img'><a href='#' class='link_pop_tab_active' onclick=fnShowpageColor('Interior')><b>Interior</b></a><img src='image/spacer.gif' width='13' height='2' class='img'></td></tr></table>";
				createCookie('strMenu',strMenu,1)
				//parent.mainFrame.innerFrame.location = "../../PageRedirector.aspx?pageurl=pages/content/SwatchInteriorInner.aspx"//"../../PageRedirector.aspx?pageurl=pages/content/AllocateInteriorPhotos.aspx";
				document.getElementById("txtTabType").innerText = "Interior";
				
				break;
		}
		fnUnselectMenusColor(strMenu);
	}

//for inactive tabs	
function fnUnselectMenusColor(strSelectedMenu)
	{
		var objSpan;
		if(strSelectedMenu != 'Exterior')
		{
			objSpan = document.getElementById('Exterior');
			objSpan.innerHTML = "<table cellspacing='0' cellpadding='0'><tr><td class='pop_inactive_tab'><img src='image/spacer.gif' width='13' height='2' class='img'><a href='#' class='link_pop_tab_inactive' onclick=fnShowpageColor('Exterior')>Exterior</a><img src='image/spacer.gif' width='13' height='2' class='img'></td></tr></table>";
		}
		
		if(strSelectedMenu != 'Interior')
		{
			objSpan = document.getElementById('Interior');
			objSpan.innerHTML = "<table cellspacing='0' cellpadding='0'><tr><td class='pop_inactive_tab'><img src='image/spacer.gif' width='13' height='2' class='img'><a href='#' class='link_pop_tab_inactive' onclick=fnShowpageColor('Interior')>Interior</a><img src='image/spacer.gif' width='13' height='2' class='img'></td></tr></table>";
		}
	}
//for active tabs
function fnShowpageGallery(strMenu)
	{
		var objSpan;
		objSpan = document.getElementById(strMenu);
		switch(strMenu)
		{
			case 'Exterior':
				objSpan.innerHTML = "<table cellspacing='0' cellpadding='0'><tr><td class='pop_active_tab'><img src='image/spacer.gif' width='13' height='2' class='img'><a href='#' class='link_pop_tab_active' onclick=fnShowpageGallery('Exterior')><b>Exterior</b></a><img src='image/spacer.gif' width='13' height='2' class='img'></td></tr></table>";
				createCookie('strMenu',strMenu,1)
				parent.mainFrame.innerFrame.location = "../../PageRedirector.aspx?pageurl=pages/gallery/ExteriorPhotos.aspx";
				
				document.getElementById("hdnUrl").value = "../../PageRedirector.aspx?pageurl=pages/gallery/ExteriorPhotos.aspx"
				
				document.getElementById("txtTabType").innerText = "Exterior";
				
				break;
			case 'Interior':
				objSpan.innerHTML = "<table cellspacing='0' cellpadding='0'><tr><td class='pop_active_tab'><img src='image/spacer.gif' width='13' height='2' class='img'><a href='#' class='link_pop_tab_active' onclick=fnShowpageGallery('Interior')><b>Interior</b></a><img src='image/spacer.gif' width='13' height='2' class='img'></td></tr></table>";
				createCookie('strMenu',strMenu,1)
				parent.mainFrame.innerFrame.location = "../../PageRedirector.aspx?pageurl=pages/gallery/InteriorPhotos.aspx";
				
				document.getElementById("hdnUrl").value = "../../PageRedirector.aspx?pageurl=pages/gallery/InteriorPhotos.aspx";
				
				document.getElementById("txtTabType").innerText = "Interior";
				
				break;
			case 'PhotoGallery':
				objSpan.innerHTML = "<table cellspacing='0' cellpadding='0'><tr><td class='pop_active_tab'><img src='image/spacer.gif' width='13' height='2' class='img'><a href='#' class='link_pop_tab_active' onclick=fnShowpageGallery('PhotoGallery')><b>Photo&nbsp;Gallery</b></a><img src='image/spacer.gif' width='13' height='2' class='img'></td></tr></table>";
				createCookie('strMenu',strMenu,1)
				parent.mainFrame.innerFrame.location = "../../PageRedirector.aspx?pageurl=pages/gallery/PhotoGalleryPhotos.aspx";
				
				document.getElementById("hdnUrl").value = "../../PageRedirector.aspx?pageurl=pages/gallery/PhotoGalleryPhotos.aspx";
				
				document.getElementById("txtTabType").innerText = "PhotoGallery";
				
				break;
			case '360View':
				objSpan.innerHTML = "<table cellspacing='0' cellpadding='0'><tr><td class='pop_active_tab'><img src='image/spacer.gif' width='13' height='2' class='img'><a href='#' class='link_pop_tab_active' onclick=fnShowpageGallery('360View')><b>360<sup>o</sup>&nbsp;View</b></a><img src='image/spacer.gif' width='13' height='2' class='img'></td></tr></table>";
				createCookie('strMenu',strMenu,1)
				parent.mainFrame.innerFrame.location = "../../PageRedirector.aspx?pageurl=pages/gallery/View360Photos.aspx";
				
				document.getElementById("hdnUrl").value = "../../PageRedirector.aspx?pageurl=pages/gallery/View360Photos.aspx";
				
				document.getElementById("txtTabType").innerHTML = "360<sup>o</sup> View";
				
				break;
			case 'Video':
				objSpan.innerHTML = "<table cellspacing='0' cellpadding='0'><tr><td class='pop_active_tab'><img src='image/spacer.gif' width='13' height='2' class='img'><a href='#' class='link_pop_tab_active' onclick=fnShowpageGallery('Video')><b>Video</b></a><img src='image/spacer.gif' width='13' height='2' class='img'></td></tr></table>";
				createCookie('strMenu',strMenu,1)
				parent.mainFrame.innerFrame.location = "../../PageRedirector.aspx?pageurl=pages/gallery/VideoPhotos.aspx";
				
				document.getElementById("hdnUrl").value = "../../PageRedirector.aspx?pageurl=pages/gallery/VideoPhotos.aspx";
				
				document.getElementById("txtTabType").innerText = "Video";
				
				break;						
		}
		fnUnselectMenusGallery(strMenu);
	}

//for inactive tabs	
function fnUnselectMenusGallery(strSelectedMenu)
	{
		var objSpan;
		if(strSelectedMenu != 'Exterior')
		{
			objSpan = document.getElementById('Exterior');
			objSpan.innerHTML = "<table cellspacing='0' cellpadding='0'><tr><td class='pop_inactive_tab'><img src='image/spacer.gif' width='13' height='2' class='img'><a href='#' class='link_pop_tab_inactive' onclick=fnShowpageGallery('Exterior')>Exterior</a><img src='image/spacer.gif' width='13' height='2' class='img'></td></tr></table>";
		}
		
		if(strSelectedMenu != 'Interior')
		{
			objSpan = document.getElementById('Interior');
			objSpan.innerHTML = "<table cellspacing='0' cellpadding='0'><tr><td class='pop_inactive_tab'><img src='image/spacer.gif' width='13' height='2' class='img'><a href='#' class='link_pop_tab_inactive' onclick=fnShowpageGallery('Interior')>Interior</a><img src='image/spacer.gif' width='13' height='2' class='img'></td></tr></table>";
		}
		if(strSelectedMenu != 'PhotoGallery')
		{
			objSpan = document.getElementById('PhotoGallery');
			objSpan.innerHTML = "<table cellspacing='0' cellpadding='0'><tr><td class='pop_inactive_tab'><img src='image/spacer.gif' width='13' height='2' class='img'><a href='#' class='link_pop_tab_inactive' onclick=fnShowpageGallery('PhotoGallery')>Photo&nbsp;Gallery</a><img src='image/spacer.gif' width='13' height='2' class='img'></td></tr></table>";
		}
		if(strSelectedMenu != '360View')
		{
			objSpan = document.getElementById('360View');
			objSpan.innerHTML = "<table cellspacing='0' cellpadding='0'><tr><td class='pop_inactive_tab'><img src='image/spacer.gif' width='13' height='2' class='img'><a href='#' class='link_pop_tab_inactive' onclick=fnShowpageGallery('360View')>360<sup>o</sup>&nbsp;View</a><img src='image/spacer.gif' width='13' height='2' class='img'></td></tr></table>";
		}
		if(strSelectedMenu != 'Video')
		{
			objSpan = document.getElementById('Video');
			objSpan.innerHTML = "<table cellspacing='0' cellpadding='0'><tr><td class='pop_inactive_tab'><img src='image/spacer.gif' width='13' height='2' class='img'><a href='#' class='link_pop_tab_inactive' onclick=fnShowpageGallery('Video')>Video</a><img src='image/spacer.gif' width='13' height='2' class='img'></td></tr></table>";
		}
	}

function fnShowpageVSM(strMenu)
	{
		var objSpan;
		objSpan = document.getElementById(strMenu);
		switch(strMenu)
		{
			case 'VSM001':
				objSpan.innerHTML = "<table cellspacing='0' cellpadding='0'><tr><td class='pop_active_tab'><img src='image/spacer.gif' width='13' height='2' class='img'><a href='#' class='link_pop_tab_active' onclick=fnShowpageVSM('VSM001')><b>VSM001</b></a><img src='image/spacer.gif' width='13' height='2' class='img'></td></tr></table>";
				createCookie('strMenu',strMenu,1)
				parent.mainFrame.innerFrame.location = "../../PageRedirector.aspx?pageurl=pages/content/VSM001File.aspx";
				
				document.getElementById("txtTabType").innerText = "VSM001";
				
				break;
			case 'VSM002':
				objSpan.innerHTML = "<table cellspacing='0' cellpadding='0'><tr><td class='pop_active_tab'><img src='image/spacer.gif' width='13' height='2' class='img'><a href='#' class='link_pop_tab_active' onclick=fnShowpageVSM('VSM002')><b>VSM002</b></a><img src='image/spacer.gif' width='13' height='2' class='img'></td></tr></table>";
				createCookie('strMenu',strMenu,1)
				parent.mainFrame.innerFrame.location = "../../PageRedirector.aspx?pageurl=pages/content/VSM002File.aspx";
				
				document.getElementById("txtTabType").innerText = "VSM002";
				
				break;
		}
		fnUnselectMenusVSM(strMenu);
	}

//for inactive tabs	
function fnUnselectMenusVSM(strSelectedMenu)
	{
		var objSpan;
		if(strSelectedMenu != 'VSM001')
		{
			objSpan = document.getElementById('VSM001');
			objSpan.innerHTML = "<table cellspacing='0' cellpadding='0'><tr><td class='pop_inactive_tab'><img src='image/spacer.gif' width='13' height='2' class='img'><a href='#' class='link_pop_tab_inactive' onclick=fnShowpageVSM('VSM001')>Exterior</a><img src='image/spacer.gif' width='13' height='2' class='img'></td></tr></table>";
		}
		
		if(strSelectedMenu != 'VSM002')
		{
			objSpan = document.getElementById('VSM002');
			objSpan.innerHTML = "<table cellspacing='0' cellpadding='0'><tr><td class='pop_inactive_tab'><img src='image/spacer.gif' width='13' height='2' class='img'><a href='#' class='link_pop_tab_inactive' onclick=fnShowpageVSM('VSM002')>Interior</a><img src='image/spacer.gif' width='13' height='2' class='img'></td></tr></table>";
		}
	}		
//page level back/forward
function fnPageLoad(strIFMenu)
	{
		try{
		var objSpan;
		
							
		switch(strIFMenu)
		{
			case 'Home':
				objSpan.innerHTML = "<table cellspacing='0' cellpadding='0'><tr><td class='tab_active'><img src='image/open_activeTab.gif' width='2' height='27' class='img'></td><td class='tab_active'><img src='image/spacer.gif' width='13' height='2' class='img'><a href='#' class='link_tabactive' onclick=fnShowpage('Home')>Home</a><img src='image/spacer.gif' width='13' height='2' class='img'></td><td><img src='image/close_activeTab.gif' width='5' height='27' class='img'></td></tr></table>";
				break;
			case 'Setup':
				objSpan.innerHTML = "<table cellspacing='0' cellpadding='0'><tr><td class='tab_active'><img src='image/open_activeTab.gif' width='2' height='27' class='img'></td><td class='tab_active'><img src='image/spacer.gif' width='13' height='2' class='img'><a href='#' class='link_tabactive' onclick=fnShowpage('Setup')>SetUp</a><img src='image/spacer.gif' width='13' height='2' class='img'></td><td><img src='image/close_activeTab.gif' width='5' height='27' class='img'></td></tr></table>";
				break;
			case 'ContentManagement':
				objSpan.innerHTML = "<table cellspacing='0' cellpadding='0'><tr><td class='tab_active'><img src='image/open_activeTab.gif' width='2' height='27' class='img'></td><td class='tab_active'><img src='image/spacer.gif' width='13' height='2' class='img'><a href='#' class='link_tabactive' onclick=fnShowpage('ContentManagement')>Content Management</a><img src='image/spacer.gif' width='13' height='2' class='img'></td><td><img src='image/close_activeTab.gif' width='5' height='27' class='img'></td></tr></table>";
				break;	
			case 'Gallery':
				objSpan.innerHTML = "<table cellspacing='0' cellpadding='0'><tr><td class='tab_active'><img src='image/open_activeTab.gif' width='2' height='27' class='img'></td><td class='tab_active'><img src='image/spacer.gif' width='13' height='2' class='img'><a href='#' class='link_tabactive' onclick=fnShowpage('Gallery')>Gallery</a><img src='image/spacer.gif' width='13' height='2' class='img'></td><td><img src='image/close_activeTab.gif' width='5' height='27' class='img'></td></tr></table>";
				break;
		}
		fnUnselectMenus(strIFMenu);
		}
		catch(err){}
	}

function createCookie(name, value, days)
{
  //alert('createCookie');
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
    }
  else var expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
 }


function readCookie(name)
{
  var ca = document.cookie.split(';');
  var nameEQ = name + "=";
  for(var i=0; i < ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1, c.length); //delete spaces
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
  return null;
}

function eraseCookie(name)
{
   createCookie(name, "", -1);
}


var win = null;
function CenterScreen(WidthSize,HeigthSize){
	var LeftPosition = (screen.width)?(screen.width-WidthSize)/2:0;
	var TopPosition  = (screen.height)?(screen.height-HeigthSize)/2:0;
	return 'top='+TopPosition+',left='+LeftPosition + ',height='+HeigthSize+',width='+WidthSize;
}	
function ShowInPopup(PageDetail,WidthSize,HeigthSize){
	var Settings = CenterScreen(WidthSize,HeigthSize) + ',resizable=no,menubar=no,location=no,scrollbars=no,status=no,toolbar=no,titlebar=no'
	win=window.open(PageDetail,'PCCAdminPopup',Settings);
	win.focus();
	return false;
}
function LoadImage(controlid)
{
	document.getElementById("imgTemp").src = "file://" + document.getElementById(controlid).value;
	
}
function GetImageSize(intWidth, intHeight)
{
	if(parseInt(document.getElementById("imgTemp").width) != intWidth && parseInt(document.getElementById("imgTemp").height) != intHeight)
	{
		alert("Image width and height is not allowed");
		return false;
	}
}

function LoadValidImage(controlid, intWidth, intHeight)
{
	
	//document.getElementById(controlid).disabled = true;
	document.getElementById("imgTemp").src = "file://" + document.getElementById(controlid).value;
	//document.getElementById(controlid).disabled = false;
	
	if(parseInt(document.getElementById("imgTemp").width) != intWidth && parseInt(document.getElementById("imgTemp").height) != intHeight)
	{	
	
		//document.getElementById(controlid).outerHTML = "<input type='file' id='flSwatchImage' runat=server class=text_area contenteditable=false size=15 onChange =\"javascript:LoadValidImage(this.id,'28','28')\" NAME=flSwatchImage>"
		document.getElementById(controlid).outerHTML = "<input type='file' id='flSwatchImage' runat=server class=text_area contenteditable=false size=15 NAME=flSwatchImage>"
		//alert(document.getElementById(controlid).outerHTML);		
		alert("Image width and height is not allowed");
		return false;
	}
} 
function trimit(x)
{
	//x=document.formname
	for(k=0;k<x.elements.length;k++)
	{
		if(x.elements[k].type=="text" || x.elements[k].type=="textarea")
		{
			splitstr=x.elements[k].value.split("");
			var i=0;
			if(splitstr[i]==" ")
			{
				x.elements[k].value="";
				while(splitstr[i]==" ")
				i++;
				for(j=i;j<splitstr.length;j++,i++)
				x.elements[k].value=x.elements[k].value+splitstr[i];
			}
			splitstr=x.elements[k].value.split("");

			i=splitstr.length-1
			if(splitstr[i]==" ")
			{
				x.elements[k].value="";
				while(splitstr[i]==" ")
				i--;
				for(j=0;j<=i;j++)
				x.elements[k].value=x.elements[k].value+splitstr[j];
			}
		}
		if(x.elements[k].type=="textarea")
		{
			setNullIfBlank(x.elements[k]);
		}
	}
}
//	Common function to set the field values in the corresponding controls in the page.
function SetValue(intPos)
{
	var controlToFocus="";
	var arr = document.getElementById("hdnAllValues").value.split("<|>");
	var arrChild = arr[intPos].split("<^>");
	var i,z;
	z=0;
	var len=arrChild.length
	for(i=0;i<len;i++)
	{
	    //alert(document.getElementById(arrChild[i].split("<~>")[0]).name + "->" +document.getElementById(arrChild[i].split("<~>")[0]).type);
	    //alert(arrChild[i].split("<~>")[1]);
	    //controlToFocus=arrChild[1].split("<~>")[0];
	    //alert(document.getElementById(arrChild[i].split("<~>")[0]).name);
		if(document.getElementById(arrChild[i].split("<~>")[0]).type =="radio")
			document.getElementById(arrChild[i].split("<~>")[0]).checked = arrChild[i].split("<~>")[1];
		else if(document.getElementById(arrChild[i].split("<~>")[0]).type=="checkbox")
		{
			if(arrChild[i].split("<~>")[1] == "True")
				document.getElementById(arrChild[i].split("<~>")[0]).checked = true;
			else
				document.getElementById(arrChild[i].split("<~>")[0]).checked = false;
		}
		else
			//	For textbox, hidden and drop down controls this block will get executed"
			if(document.getElementById(arrChild[i].split("<~>")[0]).type=="text" || document.getElementById(arrChild[i].split("<~>")[0]).type == "hidden" || document.getElementById(arrChild[i].split("<~>")[0]).type == "password" || document.getElementById(arrChild[i].split("<~>")[0]).type == "select-one")
			{
				//alert(document.getElementById(arrChild[i].split("<~>")[0]).readOnly)
				if(document.getElementById(arrChild[i].split("<~>")[0]).type=="text" && z==0)
				{
					z=i;
					controlToFocus=arrChild[i].split("<~>")[0];					
				}
				document.getElementById(arrChild[i].split("<~>")[0]).value = arrChild[i].split("<~>")[1];
			}
			else	//	For label controls this block will get executed, for that, first 3 characters need to have "lbl"
			{
				document.getElementById(arrChild[i].split("<~>")[0]).innerHTML = arrChild[i].split("<~>")[1];
			}
	}
	//alert(document.getElementById(controlToFocus).className);
	//document.getElementById(controlToFocus).focus();
}

//	Polymorphic function to set the field values in the corresponding controls in the page.
function SetValueToField(intPos,strHiddenName)
{
	var controlToFocus="";
	var arr = document.getElementById(strHiddenName).value.split("<|>");
	var arrChild = arr[intPos].split("<^>");
	var i,z;
	z=0;
	var len=arrChild.length
	for(i=0;i<len;i++)
	{
	    //alert(document.getElementById(arrChild[i].split("<~>")[0]).name + "->" +document.getElementById(arrChild[i].split("<~>")[0]).type);
	    //alert(arrChild[i].split("<~>")[1]);
	    //controlToFocus=arrChild[1].split("<~>")[0];
	    //alert(document.getElementById(arrChild[i].split("<~>")[0]).name);
		if(document.getElementById(arrChild[i].split("<~>")[0]).type =="radio")
			document.getElementById(arrChild[i].split("<~>")[0]).checked = arrChild[i].split("<~>")[1];
		else if(document.getElementById(arrChild[i].split("<~>")[0]).type=="checkbox")
		{
			if(arrChild[i].split("<~>")[1] == "True")
				document.getElementById(arrChild[i].split("<~>")[0]).checked = true;
			else
				document.getElementById(arrChild[i].split("<~>")[0]).checked = false;
		}
		else
			//	For textbox, hidden and drop down controls this block will get executed"
			if(document.getElementById(arrChild[i].split("<~>")[0]).type=="text" || document.getElementById(arrChild[i].split("<~>")[0]).type == "hidden" || document.getElementById(arrChild[i].split("<~>")[0]).type == "password" || document.getElementById(arrChild[i].split("<~>")[0]).type == "select-one")
			{
				//alert(document.getElementById(arrChild[i].split("<~>")[0]).readOnly)
				if(document.getElementById(arrChild[i].split("<~>")[0]).type=="text" && z==0)
				{
					z=i;
					controlToFocus=arrChild[i].split("<~>")[0];					
				}
				document.getElementById(arrChild[i].split("<~>")[0]).value = arrChild[i].split("<~>")[1];
			}
			else	//	For label controls this block will get executed, for that, first 3 characters need to have "lbl"
			{
				document.getElementById(arrChild[i].split("<~>")[0]).innerHTML = arrChild[i].split("<~>")[1];
			}
	}
	//alert(document.getElementById(controlToFocus).className);
	//document.getElementById(controlToFocus).focus();
}

//maxlength for TextBoxes
function CheckMaxLength(Object, MaxLen)
{
	if(Object.value.length > MaxLen)
	{   
		Object.value = Object.value.substring(0, MaxLen);
	}
}

function chkalpha(str)
{
	if (str.length < 2)
		return false;
	for (var i = 0; i < str.length; i++)
	{
		var ch = str.substring(i, i+1);
		var ch1 = str.substring(i+1, i+2);
		var ch2 = str.substring(i+2, i+3);
		if ((ch < "a" || "z" < ch) && (ch < "A" || "Z" < ch)&& (ch != ' ')&& (ch != "'")&& (ch != "."))
		{
			return false;
		}
		if (ch == ch1 && ch1 == ch2)
			return false;
	}
	return true;
	
}
function chkemail(x)
{
	fmail=x.value;
	regmail=/[a-zA-Z0-9_\-\.]+@[a-zA-Z0-9]+\.[a-zA-Z0-9.]+/
	fmailflag=fmail.match(regmail)
	if (fmailflag!=fmail)
	{
		x.focus();
		x.select();
		return false;
	}
	return true;
}
function chkusername(str)
{
	fname=str;     
	//regname=/[a-zA-Z]+[a-zA-Z0-9_\.]+[a-zA-Z0-9]+/;
	regname=/[a-zA-Z0-9_\.]+/;
	fnameflag=fname.match(regname);	
	if (fnameflag != fname && fname !="")
	{		
		return false;
	}
	return true;
}
//	CHECK THE START DATE IS LESS THAN THE END DATE
function IsSmallerEndDate(startdate,enddate)
{
	var arrSdate = startdate.split("/");
	var arrEdate = enddate.split("/");
	
	var Sday = parseInt(arrSdate[0]);
	var Eday = parseInt(arrEdate[0]);
	var Smon = parseInt(arrSdate[1]) - 1;	//	January Starts with 0
	var Emon = parseInt(arrEdate[1]) - 1;	//	January Starts with 0
	var Syear = parseInt(arrSdate[2]);
	var Eyear = parseInt(arrEdate[2]);

	var dateS;
	var dateE;
	
	dateS = new Date();
	dateE = new Date();
	
	dateS.setFullYear(Syear,Smon,Sday);
	dateE.setFullYear(Eyear,Emon,Eday);

	if(dateS >= dateE)
	{
		return true;
	}
	else
	{
		return false;
	}
}
function clearcancel()
{
	document.getElementById("btnNew").style.display = "none";
}