﻿<!--

var isNN = document.layers ? true : false;
var isIE = document.all ? true : false;
var IFrameObj; // our IFrame object

// validating email using Javascript with remoting








/*   RELATED FUNCTIONS START  */

function CreateCookie(name,value,days)
{
	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 nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return '';
}

function EraseCookie(name)
{
	createCookie(name,"",-1);
}

function CallToServer(URL,indexi) {

	ranDomStr=Math.random();
	ranDomStr=ranDomStr*10000000000000000000;	
	var RSIExtra = "";
	if(indexi){
		RSIExtra = indexi;
		if(IFrameObj)
			IFrameObj = null;
	}else
		RSIExtra="";
		
	
	
	if(!URL.indexOf("rnd=")!=-1){
		if(URL.indexOf("?")!=-1)
				URL = URL + "&rnd=" + ranDomStr;
		else
				URL = URL + "?rnd=" + ranDomStr;
	}
  if (!document.createElement) {return true};
  var IFrameDoc;  
  
  if (!IFrameObj && document.createElement) {
  
    // create the IFrame and assign a reference to the
    // object to our global variable IFrameObj.
    // this will only happen the first time 
    // callToServer() is called
    var tempIFrame=document.createElement('iframe');
    tempIFrame.setAttribute('id','RSIFrame'+RSIExtra);
    tempIFrame.setAttribute('src','javascript:false');
    tempIFrame.style.border='0px';
    tempIFrame.style.width='0px';
    tempIFrame.style.height='0px';
    
    IFrameObj = document.body.appendChild(tempIFrame);
	
  
    if (document.frames) {
      // this is for IE5 Mac, because it will only
      // allow access to the document object
      // of the IFrame if we access it through
      // the document.frames array
      IFrameObj = document.frames['RSIFrame'+RSIExtra];
    }
  }
  
  if (navigator.userAgent.indexOf('Gecko') !=-1 && !IFrameObj.contentDocument) {
    // we have to give NS6 a fraction of a second
    // to recognize the new IFrame
    setTimeout('callToServer("'+URL + '")',10);    
    return false;
  }
  
  if (IFrameObj.contentDocument) {
    // For NS6
    IFrameDoc = IFrameObj.contentDocument; 
  } else if (IFrameObj.contentWindow) {
    // For IE5.5 and IE6
    IFrameDoc = IFrameObj.contentWindow.document;
  } else if (IFrameObj.document) {
    // For IE5
    IFrameDoc = IFrameObj.document;
  } else {
    return true;
  }
  
  IFrameDoc.location.replace(URL);
  
  return false;
}

/// <summary>
/// Read attribute attr value from querystring
/// </summary>
function Querystring(attr){
	// @attr As String
	if(!attr)
		attr = "";
	var urli = document.location.toString();
	this.exists = false;
	this.value = "";
	var VALUES = new Array();
	var KEYS = new Array();
	var VALS = new Array();
	if(urli.indexOf("?") != -1){
		var Qs = urli.split("?")[1].split("#");
		var qs = Qs.join("").split("&");
		for(k=0;k<qs.length;k++){
			var atKey = qs[k].split("=")[0];
			var atVal = qs[k].split("=")[1];
			if(atVal != ""){
				VALUES.push(atKey + "=" + atVal);
				KEYS.push(atKey);				
				VALS.push(atVal);
			}
			if(atKey.toLowerCase() == attr.toLowerCase()){
				this.exists = true;
				this.value = atVal;
			}			
		}
	}
	this.values = VALUES;
	this.keys = KEYS;
	this.vals = VALS;
}

function GetObj(name)
{
  if (document.getElementById && name !="")
  {
  
  	if(document.getElementById(name)){
	  	this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
	}else{
		alert("Object " + name + " does not exist")
	}
  }
  else if (document.all && name !="")
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers && name !="")
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}
/// <summary>
/// Find object horizontal position</summary>
/// <param name="obj">Javascript Object</param>
/// <returns>position in pixels from the left within the current document. Integer</returns>
function FindPosX(obj)
{
	var curleft = 0;
	if(obj){
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curleft += obj.offsetLeft;
				obj = obj.offsetParent;
			}
		}
		else if (obj.x)
			curleft += obj.x;
				
	}
	return curleft;

}
/// <summary>
/// Find object vertical position</summary>
/// <param name="obj">Javascript Object</param>
/// <returns>position in pixels from the top within the current document. Integer</returns>
function FindPosY(obj)
{
	var curtop = 0;

	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

/// <summary>
/// Move layer to specified position</summary>
/// <param name="OBJ">Javascript Object</param>
/// <param name="posX">Horizontal position X in pixels, Integer</param>
/// <param name="posY">Vertical position Y in pixels, Integer</param>
function MoveLayer(OBJ,posX,posY){
	if(OBJ != undefined){
		OBJ.style.left=posX+'px';
		OBJ.style.top=posY+'px';
	}

}
/// <summary>
/// Show or hide layer</summary>
/// <param name="divId">ID of object to be manipulated. String</param>
/// <param name="action">"show" or something else, String</param>
function ShowDiv(divId,action,IFrameTrick){

	if(!new getObj(divId).obj)
		window.status(divId + ' does not exist');

	if(!IFrameTrick)
		var trickIt = false;
	else
		var trickIt = true;

	if(trickIt){
			// IE NEEDS Iframe BEHIND LAYER IN ORdER TO SHOW IT OVER SELECT LIST
			var IfrRef = document.getElementById('dummyIframe'); 
			
	}
	if(action=='show'){
		new getObj(divId).style.display='block';
		if(trickIt){
			var saveLayer = new getObj(divId);
			IfrRef.style.width = saveLayer.obj.offsetWidth; 
			IfrRef.style.height = saveLayer.obj.offsetHeight; 
			IfrRef.style.top = saveLayer.style.top; 
			IfrRef.style.left = saveLayer.style.left; 
			IfrRef.style.zindex = saveLayer.style.zindex - 1; 
			IfrRef.style.display = "block"; 
		}
	}else{
		new getObj(divId).style.display='none';
		if(trickIt){
			IfrRef.style.width = "0px"; 
			IfrRef.style.height = "0px"; 
			IfrRef.style.top = "0px"; 
			IfrRef.style.left = "0px"; 
			IfrRef.style.zindex = -1; 
			IfrRef.style.display = "none"; 
		}
	}
}
/// <summary>
/// Checks whether object is within horizontal boundaries of Browser window</summary>
/// <param name="obj">Javascript Object</param>
/// <param name="offSet">optional user specified offset</param>
/// <returns>positive Integer if object is inside, otherwise value is negative</returns>
function IsInsideWindowX(obj,offSet){

	if(offSet == "")
		offSet = 0
	var objRight = parseInt(findPosX(obj))+parseInt(obj.offsetWidth)+parseInt(offSet);
	var W = document.body.clientWidth+document.body.scrollLeft;
	if(objRight>W)
		return W-objRight;
	else
	    return objRight;
}

/// <summary>
/// Checks whether object is within vertical boundaries of Browser window</summary>
/// <param name="obj">Javascript Object</param>
/// <param name="offSet">optional user specified offset</param>
/// <returns>positive Integer if object is inside, otherwise value is negative</returns>
function IsInsideWindowY(obj,offSet){

	if(offSet == "")
		offSet = 0
	var objVertical = parseInt(findPosY(obj))+parseInt(obj.offsetHeight);
	var H = document.body.clientHeight+document.body.scrollTop;
	if(objVertical>H)
		return H-objVertical;
	else
		return 0;
}

function FindImage(name, doc) {
	var i, img;
	for (i = 0; i < doc.images.length; i++)
	if (doc.images[i].name == name)
	    return doc.images[i];
	for (i = 0; i < doc.layers.length; i++)
	if ((img = findImage(name, doc.layers[i].document)) != null) {
	    img.container = doc.layers[i];

	    return img;
	}
	return null;
}

function GetImage(name) {
	if (isNN) {
	return FindImage(name, document);
	}
	if (isIE){
	return eval('document.all.' + name);
	}else if (document.images) {
	return eval('document.images.' + name);
	}	

	else{
		return document.getElementById(name);
	}
	return null;
}
function GetImagePageLeft(img) {
	  var x, obj;
	  if (isNN) {
	    if (img.container != null)
	      return img.container.pageX + img.x;
	    else
	      return img.x;
	  }
	  if (isIE || document.images) {
	    x = 0;
	    obj = img;
	    while (obj.offsetParent != null) {
	      x += obj.offsetLeft;
	      obj = obj.offsetParent;
	    }
	    x += obj.offsetLeft;
	    return x;
	  }

	  return -1;
	}

function GetImagePageTop(img) {
	  var y, obj;
	  if (isNN) {
	    if (img.container != null)
	      return img.container.pageY + img.y;
	    else
	      return img.y;
	  }
	  if (isIE || document.images) {
	    y = 0;
	    obj = img;
	    while (obj.offsetParent != null) {
	      y += obj.offsetTop;
	      obj = obj.offsetParent;
	    }
	    y += obj.offsetTop;
	    return y;
	  }
	  return -1;
	}

//-->
