//This prototype is provided by the Mozilla foundation and is distributed under the MIT license.
//http://www.ibiblio.org/pub/Linux/LICENSES/mit.license
    if (!Array.prototype.indexOf)
    {
      Array.prototype.indexOf = function(elt /*, from*/)
      {
        var len = this.length;
        var from = Number(arguments[1]) || 0;
        from = (from < 0)? Math.ceil(from): Math.floor(from);
        if (from < 0)from += len;
        for (; from < len; from++){ if (from in this && this[from] === elt) return from; }
        return -1;
      };
   }

  var env_prod = 0, env_stage = 1, env_dev = 2;
  env = env_prod;

  function getEnv() {
      var url = document.location.href.toLowerCase();
	  var result = env_prod;
	  for (var i = 0; i < 3; i++) {	if (url.indexOf("//" + dynamicDomains[i])>= 0){return i; }}
	  for (var i = 0; i < 3; i++) {
		  	  for (var j=0; j < staticDomains[i].length; j++){
				  if (url.indexOf("//" + staticDomains[i][j])>= 0){  return i;  }
			  }
	  }
	 return result;
  }
    dynamicDomains = [];
    dynamicDomains[env_prod] = "asia.acuvue.com";
    dynamicDomains[env_stage] = "asia-staging.acuvue.com";
    dynamicDomains[env_dev] = "asia.av.dev.hk.agenda-asia.com";
	
    staticDomains = [];
	staticDomains[env_prod] = [];
    staticDomains[env_prod][0] = "www.acuvue.co.nz";
	staticDomains[env_prod][1] = "acuvue.co.nz";
	staticDomains[env_stage] = [];
    staticDomains[env_stage][0] = "stage.acuvue.co.nz";
	staticDomains[env_dev] = [];
    staticDomains[env_dev][0] = "nz.revamp.av.dev.hk.agenda-asia.com";
    env = getEnv();
    var env_protocol = "http://";
    if (env == env_prod) {        env_protocol = "https://";   }

    us_wwwroot = "http://" + staticDomains[env][0] + "/";
    wwwroot_dynamic = "http://" + dynamicDomains[env] + "/nz/av/";
    wwwroot_dynamicssl = env_protocol + dynamicDomains[env] + "/ap/forms/nz/av/";
    www_root_oasysform = env_protocol + dynamicDomains[env] + "/ap/forms/nz/av/oasys/";
    myacuvue_ssl = env_protocol + dynamicDomains[env] + "/ap/forms/nz/av/app/";

/*no right click*/
/*var message="";
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

document.oncontextmenu=new Function("return false")
*/

/*
var cc_tagVersion = "1.0";
var cc_accountID = "1167397301";
var cc_marketID =  "17";
var cc_protocol="http";
var cc_subdomain = "convctr";
if(location.protocol == "https:")
{
    cc_protocol="https";
     cc_subdomain="convctrs";
}
var cc_queryStr = "?" + "ver=" + cc_tagVersion + "&aID=" + cc_accountID + "&mkt=" + cc_marketID +"&ref=" + escape(document.referrer); var cc_imageUrl = cc_protocol + "://" + cc_subdomain + ".overture.com/images/cc/cc.gif" + cc_queryStr; var cc_imageObject = new Image(); cc_imageObject.src = cc_imageUrl;
*/

/*open popup*/
function goToExternal(url) {
	/*if (url=="http://www.mydr.com.au/Optometrists/") {
		ni_LoadUrl(vparent_url+global_foptometrist_spage, global_foptometrist_stitle);
	}*/
	var response = confirm("Clicking on this link will take you to a web site to which our Privacy Policy does not apply. You are solely responsible for your interactions with other web sites.")
	if (response)	{ 
		window.open(url);
	}	
}
function openLegalWindow(url) {
	var legalWindow;
	if (legalWindow == null){
		legalWindow = window.open(url,legalWindow,'width=490,height=320,left=0,top=0,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no');
	}
	else if (legalWindow.closed){
		legalWindow = window.open(url,legalWindow,'width=490,height=320,left=0,top=0,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no');
	}
	legalWindow.focus();
}

function openPrivacyWindow(url) {
	var privacyWindow;
	if (privacyWindow == null){
		privacyWindow = window.open(url,privacyWindow,'width=490,height=320,left=0,top=0,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no');
	}
	else if (privacyWindow.closed){
		privacyWindow = window.open(url,privacyWindow,'width=490,height=320,left=0,top=0,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no');
	}
	privacyWindow.focus();
}

function doThisPreload(){
	if (document.images){
		var these_images = new Array('/images/why_roll_left_2020_off.gif','/images/why_roll_left_2020_on.gif','/images/why_roll_left_health_off.gif','/images/why_roll_left_health_on.gif','/images/why_roll_left_trust_off.gif','/images/why_roll_left_trust_on.gif','/images/why_roll_left_cost_off.gif','/images/why_roll_left_cost_on.gif','/images/why_roll_left_pioneer_off.gif','/images/why_roll_left_pioneer_on.gif','/images/why_roll_left_uv_off.gif','/images/why_roll_left_uv_on.gif','/images/why_roll_copy_2020.gif','/images/why_roll_copy_2020.gif','/images/why_roll_copy_2020.gif','/images/why_roll_copy_2020.gif','/images/why_roll_copy_cost.gif','/images/why_roll_copy_health.gif','/images/why_roll_copy_pioneer.gif','/images/why_roll_copy_trust.gif','/images/why_roll_copy_uv.gif','/images/why_roll_top_2020.gif','/images/why_roll_top_health.gif','/images/why_roll_top_trust.gif','/images/why_roll_top_cost.gif','/images/why_roll_top_pioneer.gif','/images/why_roll_top_uv.gif');
		preloadImages(these_images);
	}
}

function preloadDaImages(these_images_array) {
	for(loop = 0; loop < these_images_array.length; loop++){
		var alf_image = new Image();
		alf_image.src = these_images_array[loop];
	}
}

function rollIt(img,newImg) {
	if (document.images) {
		document.images[img].src = newImg;
	}
}

openWin = function(url,name,width,height,xpos,ypos,chrome,scroll,resizable){
  var x, y, w, h, moveX=0, moveY=0, features="";
  chrome = chrome ? "yes" : "no";
  scroll = scroll ? "yes" : "no";
  resizable = resizable ? "yes" : "no";
  features += "toolbar="+chrome+",location="+chrome+",status="+chrome+",menubar="+chrome;
  features += ",scrollbars="+scroll+",resizable="+resizable;
  if(width) features += ",width="+width;
  if(height) features += ",height="+height;
  if(xpos && window.screen){
    w = window.screen.availWidth;
    width = parseInt(width);
    switch(xpos){
      case "left": x = 0; break;
      case "center": x = (w-width)/2; break;
      case "right": x = w-width; break;
      default: x = xpos;
    }
    features += ",screenX="+x+",left="+x;
    var moveX = x;
  }
  if(ypos && window.screen){
    h = window.screen.availHeight;
    height = parseInt(height);
    switch(ypos){
      case "top": y = 0; break;
      case "middle": y = (h-height)/2; break;
      case "bottom": y = h-height; break;
      default: y = ypos;
    }
    features += ",screenY="+y+",top="+y;
    var moveY = y;
  }
  features +=",left="+moveX+",top="+moveY;
//  openWinReference = window.open('',name,features);
eval("openWinReference = window.open(url, name, features);");  
//  if(moveX || moveY){
 //   // position the window for browsers that don't recognize screenX, screenY
  //  openWinReference.moveTo(moveX,moveY);
//  }
 //   openWinReference = window.open(url,name);
	openWinReference.focus();
}

/*openScroll = function(url,name,width,height){
  openWin(url,name,width,height,false,false,false,"scroll");
}
openCenter = function(url,name,width,height){
  openWin(url,name,width,height,"center","middle");
}
openCenterScroll = function(url,name,width,height){
  openWin(url,name,width,height,"center","middle",false,"scroll");
}
openFull = function(url,name){
  openWin(url,name,false,false,false,false,"chrome","scroll");
}*/

function openWinTVC(URL) {

  newWindow=window.open(URL, 'nTVC', target="_self");
//ow = window.open(URL,"composerwindow", "toolbar=no,
//  width=350,height=400,status=no,scrollbars=yes,resize=no,menubar=no");
}




function openNewWindow(URL){ 
  openWin(URL,"nWin",794,600,"center","middle",false,"scroll");
//  newWindow=window.open(URL, 'nWin', 'scrollbars=yes, width=794,height=600'); 
}

function openNewWindow2(URL){
window.opener.openWin(URL,"nWin",794,600,"center","middle",false,"scroll");
window.focus();
//  newWindow=window.open(URL, 'nWin', 'scrollbars=yes, width=794,height=600'); 
}

function openWhichCon3(URL){ 
  openWin(URL,"nWin",595,400,"center","middle");
//  newWindow=window.open(URL, 'nWin', 'scrollbars=yes, width=794,height=600'); 
}

/*Pop up window*/
function openLensAdvisor(URL){
	openWin(URL, 'lensAdvisor',640,680,'center','middle',false,'');
}

function openStoreLocator(URL) {
	URL=wwwroot_dynamic+'storelocator/'+URL;
	window.location = URL;
}

function openENews(URL){ 
openWin(URL,"eNews",595,400,"center","middle");

}

function openWhichCon(URL){ 
URL=us_wwwroot+URL;
//  openWin(URL,"nWin1",420,570,"center","middle");
openWin(URL,"nWin1",595,400,"center","middle");
//   newWindow=window.open(URL, 'nWin1', 'scrollbars=no,width=420,height=570'); 
}

function openWhichCon2(URL){ 
//window.close();
URL=us_wwwroot+URL;
//window.opener.openWin(URL,"nWin1",595,400,"center","middle");
openWin(URL,"nWin1",595,400,"center","middle");
}

/*
function openTVC(URL){ 
  openWin(URL,"nTVC",400,370,"center","middle");
//   newWindow=window.open(URL, 'nTVC', 'scrollbars=no,width=380,height=360'); 
}
*/


function openTVC(URL){ 
  oNewWindow = window.open(URL ,"_self")
//  newWindow=window.open(URL, 'nTVC', target="_self");
//   newWindow=window.open(URL, 'nTVC', 'scrollbars=no,width=380,height=360'); 
}







function openForm(URL){ 
URL=wwwroot+URL;
  openWin(URL,"eFPP",613,640,"center","middle",false,"scroll");
//   newWindow=window.open(URL, 'eFPP', 'scrollbars=yes,width=613,height=640'); 
}

function openTrial(URL){ 
  openWin(URL,"nTrial",800,595,"center","middle",false,"scroll");
//  newWindow=window.open(URL, 'nTrial', 'scrollbars=yes,width=613 ,height=450'); 
}

function openCleanStep(URL){ 
  openWin(URL,"nClean",720,480,"center","middle");
//   newWindow=window.open(URL, 'nTrial', 'scrollbars=yes,width=613 ,height=450'); 
}

function openPromotion(URL){ 
  openWin(URL,"nECP",550,555,"center","middle",false,"");
//   newWindow=window.open(URL, 'nTrial', 'scrollbars=no,width=615 ,height=740'); 
}

function openECP(URL){ 
  openWin(URL,"nECP",615,740,"center","middle",false,"scroll");
//   newWindow=window.open(URL, 'nTrial', 'scrollbars=yes,width=615 ,height=740'); 
}

function openSegmnt(URL){ 
  openWin(URL,"nSegment",420,750,"right","top",false,"");
//   newWindow=window.open(URL, 'nTrial', 'scrollbars=yes,width=615 ,height=740'); 
}

function SegmntopenerURL(URL){
	if (window.opener!= null ) {	
		window.opener.location=us_wwwroot+URL;
		window.focus();
		return; 
	}else{
		window.location=us_wwwroot+URL;
		window.focus();
		return; 		
	}
}

function openerURL(URL){
	if (window.opener!= null) {	
		if (window.opener.opener!=null) {
			window.opener.opener.location=URL;
			window.opener.opener.focus();
	//		window.close();
			return; 
		}else {
			window.opener.location=URL;
			window.opener.focus();
	//		window.close();
			return; 
		}
	}else{
		window.location=URL;
		window.focus();
		return; 		
	}
}

function openerURL2(URL){
	URL=wwwroot+URL;	
	if (window.opener!= null) {	
		window.opener.location=URL;
		window.opener.focus();
//		window.close();
		return; 
	}else{
		window.location=URL;
		window.focus();
		return; 		
	}
}

function openURL(URL){
	URL=wwwroot+URL;
	window.location=URL;
}

function openOlympic(url,te_page,te_title) {
    if (!te_page) var te_page = "VisionChallengeGame"; //<-- see this part.
	if (!te_title) var te_title = "AV_Life-Interactive|VisionChallengeGame"; //<-- see this part.
	olympicWindow = window.open(url,'olympic');
	if(typeof window.ni_LoadUrl == 'function')
	{
		ni_LoadUrl(vparent_url+te_page, te_title);
	}
	olympicWindow.focus();
}

function writeObject(str){
	document.write(str);
}


function forwardFriendsButton(){
//	document.write('<input type="image" src="'+wwwroot+'images/forwardFriends/forwardFriend_btn.jpg" onclick="openForwardFriendsWindow()">');
	//document.write('<input type="image" src="images/forwardFriends/forwardFriend_btn.jpg" onclick="openForwardFriendsWindow()">');
	document.write('');
}

function openForwardFriendsWindow(){
	var path = escape(document.location.pathname);
	var title = escape(document.title);
//	window.open(wwwroot+"common/forwardFriends.aspx?url="+path+"&title="+title, "ForwardFriends", "width=613,height=650,scrollbars=yes");
	openWin(wwwroot+"common/forwardFriends.aspx?url="+path+"&title="+title+"&ec=big5","ForwardFriends",613,650,"center","middle",false,"scroll");
	
}

function AjaxHttpPost(urlString, queryString, responseHandler) {
	this.ready = false;
	this.responseText = null;

  var xmlHttpReq = false;
  var self = this;

	self.xmlHttpReq = createAjaxObject();  
  self.xmlHttpReq.open('POST', urlString, true);
  self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  self.xmlHttpReq.onreadystatechange = function(){
		if (self.xmlHttpReq.readyState == 4) {
				responseHandler(self.xmlHttpReq.responseText);
		}
  }
  self.xmlHttpReq.send(queryString);
}

function createAjaxObject(){
	var ajaxObj;

	try{
			ajaxObj = new ActiveXObject("Msxml2.XMLHTTP");
	}catch(ex){
		try{
			ajaxObj = new ActiveXObject("Microsoft.XMLHTTP");
		}catch(ex){
			ajaxObj = new XMLHttpRequest();
		}
	}
	return ajaxObj;
}

/****************************************************************************************************/
var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
// Handle all the FSCommand messages in a Flash movie.
function index_DoFSCommand(command, args) {
	var indexObj = isInternetExplorer ? document.all.index : document.index;
	eval(command+"('"+args+"');");
}
// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub index_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call index_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}
// Handle all the FSCommand messages in a Flash movie.
function topmenu_DoFSCommand(command, args) {
	var indexObj = isInternetExplorer ? document.all.index : document.index;
	eval(command+"('"+args+"');");
}
// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub topmenu_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call topmenu_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}

//function goto(URL){
//	alert(URL);
//}
	
function goto(URL){
	URL = URL.replace(/acuvue_care/,"acuvue_life");
	var vparent_url = removetrackquerystring(window.location.href,"source");
	switch (URL)
	{
		
		case "index.html":
		window.location=us_wwwroot+URL;
		break;
		case "products/index.html":
		window.location=us_wwwroot+URL;
		break;
		case "products/av1_moist.html":
		window.location=us_wwwroot+URL;
		break;
		case "products/av1_1day.html":
		window.location=us_wwwroot+URL;
		break;
		case "products/av2_acuvue2.html":
		window.location=us_wwwroot+URL;
		break;
		case "products/av2u_advance.html":
		window.location=us_wwwroot+URL;
		break;
		case "products/av1_define.html":
		window.location=us_wwwroot+URL;
		break;
		case "products/av1_1day_astig.html":
		window.location=us_wwwroot+URL;
		break;
		case "products/av2usp_advance_astig.html":
		window.location=us_wwwroot+URL;
		break;
		case "products/av2u_oasys_astig.html":
		window.location=us_wwwroot+URL;
		break;
		case "products/av2sp_bifocal.html":
		window.location=us_wwwroot+URL;
		break;
		case "products/av2u_oasys.html":
		window.location=us_wwwroot+URL;
		break;
		case "contact-lenses-products/acuvue-trueye-contacts.html":
		window.location=us_wwwroot+URL;
		break;
		case "contact-lenses-products/acuvue-trueye-contacts.html?source=200902-BANNER-Home-HomePage-Right-Slot1-Rotation1":
		window.location=us_wwwroot+URL;
		break;
		case "products/av2u_oasys_astig.html?source=banner_homepage_slot1_rotation1":
		window.location=us_wwwroot+URL;
		break;
		case "products/av1_clear.html":
		window.location=us_wwwroot+URL;
		break;
		case "acuvue_care/acuvue_selection.html?fte_stitle=Home|Home_Page|which_acuvue_is_best_for_me":
		openWhichCon(URL);
		break;
		case "acuvue_life/acuvue_selection.html?fte_stitle=Home|Home_Page|which_acuvue_is_best_for_me":
		openWhichCon(URL);
		break;
		case "acuvue_care/acuvue_selection.html":
		openWhichCon(URL);
		break;
		case "acuvue_life/acuvue_selection.html":
		openWhichCon(URL);
		break;
		case "promotions/index.html":
		window.location=us_wwwroot+URL;
		break;
		case "acuvue_care/index.html":
		window.location=us_wwwroot+"acuvue_life/index.html";
		break;
		case "acuvue_care/eyes.html":
		window.location=us_wwwroot+"acuvue_life/eyes.html";
		break;
		case "acuvue_care/contact_lens.html":
		window.location=us_wwwroot+"acuvue_life/contact_lens.html";
		break;
		case "acuvue_care/acuvue.html":
		window.location=us_wwwroot+"acuvue_life/acuvue.html";
		break;
		case "acuvue_care/faq.html":
		window.location=us_wwwroot+"acuvue_life/faq.html";
		break;
		case "acuvue_life/index.html":
		window.location=us_wwwroot+URL;
		break;
		case "acuvue_life/index.html?section=0":
		window.location=us_wwwroot+URL;
		break;	
		case "acuvue_life/index.html?section=1":
		window.location=us_wwwroot+URL;
		break;	
		case "acuvue_life/index.html?section=2":
		window.location=us_wwwroot+URL;
		break;
		case "acuvue_life/index.html?section=3":
		window.location=us_wwwroot+URL;
		break;		
		case "acuvue_life/eyes.html":
		window.location=us_wwwroot+URL;
		break;
		case "acuvue_life/contact_lens.html":
		window.location=us_wwwroot+URL;
		break;
		case "acuvue_life/acuvue.html":
		window.location=us_wwwroot+URL;
		break;
		case "acuvue_life/faq.html":
		window.location=us_wwwroot+URL;
		break;
		case "products/wheretofind.aspx":
		window.location=us_wwwroot+URL;
		break;
		case "my_acuvue/login.aspx":
		window.location=us_wwwroot+URL;
		break;
		case "my_acuvue/login.aspx?action=login":
		window.location=us_wwwroot+URL;
		break;
		case "about_acuvue/index.html":
		window.location=us_wwwroot+URL;
		break;
		case "about_acuvue/our_credo.html":
		window.location=us_wwwroot+URL;
		break;
		case "about_acuvue/sight_kids.html":
		window.location=us_wwwroot+URL;
		break;
		case "about_acuvue/firstDCL_story.html":
		window.location=us_wwwroot+URL;
		break;
		case "about_acuvue/acuvue_school.html":
		window.location=us_wwwroot+URL;
		break;
		case "http://www.acuvuemoist.com.sg":
		window.open(URL)
		break;
		case "http://www.moist.acuvue.co.nz":
		window.open(URL)
		var vparent_url = window.location.href;
		if (vparent_url.indexOf(".html")!=-1)
			vparent_url = vparent_url + "/";
		ni_LoadUrl(vparent_url+'Slot2', 'PromoBanners-Homepage-Slot2');
		break;
		case "http://www.define.com.sg":
		window.open(URL)
		break;
		case "http://www.acuvueteens.com.sg":
		window.open(URL)
		break;
		case "aveeno_nz.asp":
		window.open(wwwroot_banner2+URL)
		break;
		case "newsletter/eNewsLetter_Registration.asp":
		openENews(wwwroot_dynamicssl+URL+"?source=Home_Homepage_sidepopup");
		break;
		case "segmentation/glasses.html":
		openSegmnt(us_wwwroot+URL);
		break;
		case "segmentation/non_acuvue.html":
		openSegmnt(us_wwwroot+URL);
		break;
		case "http://clk.atdmt.com/OMA/go/cvxxeacu0010000004oma/direct/01/":
		window.open(URL);
		ni_LoadUrl(vparent_url+'Slot1-Rotation1', 'PromoBanners-Homepage-Slot1-Rotation1');
		break;
		case "segmentation/acuvue.html":
		openSegmnt(us_wwwroot+URL);
		break;
		default:
		break;
	}
}
/*AC LIFE FUNCTIONS BY BLUE INTERACTIVE MARKETING */
function switch_aclife(menu, init) {
	allMenu = document.getElementById("rightNav").getElementsByTagName("table");
	allSpan = document.getElementById("rightNav").getElementsByTagName("span");
	var len = allMenu.length;
	for (var i = 0; i < len; i++) {
		if (i == menu) {
			allMenu[i].style.display = (allMenu[i].style.display == "none") ? "block" : "none" ;
		} else {
			allMenu[i].style.display = "none";
		}
		if (i == menu) {
			allSpan[i].className = (allSpan[i].className == "sub_header") ? "sub_header down" : "sub_header";
		} else {
			allSpan[i].className = "sub_header";
		}
		if (init) {
			allMenu[menu].style.display = "block";
			allSpan[menu].className = "sub_header down";
		}
	}
}

function querySt(ji) {
	hu = window.location.search.substring(1);
	gy = hu.split("&");
	for (i=0;i<gy.length;i++) {
		ft = gy[i].split("=");
		if (ft[0] == ji) {
			return ft[1];
		}
	}
	return null;
}

/*END AC LIFE FUNCTIONS BY BLUE INTERACTIVE MARKETING */
function getQueryVariable(variable)
{ 
  var query = window.location.search.substring(1); 
  var vars = query.split("&"); 
  for (var i=0;i<vars.length;i++) { 
    var pair = vars[i].split("="); 
    if (pair[0] == variable) { 
      return pair[1]; 
    } 
  } 
  return '';
} 

function ni_seeClearlyTrackHit(pageName)
{
	var trackingURL;
  if (getQueryVariable("referrer") != null && getQueryVariable("referrer") != '')
			trackingURL = getQueryVariable("referrer") + "/";
	else
	{
    if (document.URL.indexOf('?') != -1)
			trackingURL = document.URL.substr(0, document.URL.indexOf('?')) + "/";
		else	
			trackingURL = document.URL + "/";
  }
  title = getSeeClearlyTrackHitTitle(pageName);

	if (title != "")
	{
  	//alert("title="+title+ " // URL="+trackingURL + pageName);
		return ni_TrackHit(global_te_server, global_te_sitecode, '', '', '', '', '', '', title, trackingURL+pageName, 1, '', '', '', '', '');
  }
}

function vedio_eventTrackHit(pageName)
{
	var title = document.title;
	var temp = document.URL;
	
	if (document.URL.indexOf('?') != -1)
			tempURL = document.URL.substr(0, document.URL.indexOf('?')) + "/";
		else	
			tempURL = document.URL + "/";
  
	var tempURL = temp.split("//")[1];
	var trackingURL = "http://" + tempURL + "/" + pageName;
	
	return ni_TrackHit(global_te_server, global_te_sitecode, '', '', '', '', '', '', title, trackingURL, 1, '', '', '', '', '');
}

function ni_eventTrackHit(pageName) 
{  
	try{
  var title = (getQueryVariable("fte_stitle") == "") ?window.opener.document.title:getQueryVariable("fte_stitle");
	}catch(ex){
		return;}
	
  var temp = (GetQueryStringVal("fparent_url") == "")?window.opener.location.href:GetQueryStringVal("fparent_url");
	  
  if (document.URL.indexOf('?') != -1){
			tempURL = document.URL.substr(0, document.URL.indexOf('?'));
  }
	else{
  			tempURL = document.URL;
  }
  
  var tempURL = temp.split("//")[1];  
  if (tempURL.lastIndexOf("/") != tempURL.length - 1){
		tempURL += "/";
  }	
  var trackingURL = "http://" + tempURL + pageName;
	
  return ni_TrackHit(global_te_server, global_te_sitecode, '', '', '', '', '', '', title, trackingURL, 1, '', '', '', '', '');
}


function ni_avlTrackHit(pageName)
{
	var trackingURL;
  if (getQueryVariable("referrer") != null && getQueryVariable("referrer") != '')
			trackingURL = getQueryVariable("referrer") + "/";
	else
	{
    if (document.URL.indexOf('?') != -1)
			trackingURL = document.URL.substr(0, document.URL.indexOf('?')) + "/";
		else	
			trackingURL = document.URL + "/";
  }
  title = getTrackHitTitle(pageName, trackingURL);

	if (title != "")
	{
  	//	alert("title="+title+ " // URL="+trackingURL + pageName);
		return ni_TrackHit(global_te_server, global_te_sitecode, '', '', '', '', '', '', title, trackingURL+pageName, 1, '', '', '', '', '');
  }
}

function avlOpenWin(url,name,width,height,xpos,ypos,chrome,scroll,resizable){
	var currentURL;
	if (document.URL.indexOf('?') != -1)
		currentURL = document.URL.substr(0, document.URL.indexOf('?'));
	else	
		currentURL = document.URL;
	//currentURL = currentURL.replace("#", "");
	url += "?referrer=" + currentURL;
	openWin(url,name,width,height,xpos,ypos,chrome,scroll,resizable);
}


function getSeeClearlyTrackHitTitle(pageName)
{
  var title = "";
  var pageName = pageName.toLowerCase();
	
		
	if (pageName.match("homepage_start") ||
			pageName.match("homepage_end"))
	{
		title = "SeeClearly|Home|" + pageName;
	}
	
	else if (pageName.match("gs_main_start") ||
			pageName.match("gs_main_end") ||
			pageName.match("gs_what_is_astig_start") ||
			pageName.match("gs_what_is_astig_end") ||
			pageName.match("gs_what_causes_it_start") ||
			pageName.match("gs_what_causes_it_end") ||
			pageName.match("gs_astig_possible_sign_start") ||
			pageName.match("gs_astig_possible_sign_end") ||
			pageName.match("gs_can_astig_correct_start") ||								
			pageName.match("gs_can_astig_correct_end") ||
			pageName.match("gs_sally_answering_start") ||	
			pageName.match("gs_sally_answering_complete"))
	{
		title = "SeeClearly|Get Sharp|" + pageName;
	}		

	else if (pageName.match("fg_main_start") ||
			pageName.match("fg_main_end"))
	{
		title = "SeeClearly|Fun & Games|" + pageName;
	}	
	else if (pageName.match("fg_hidenseek_start") ||
			pageName.match("fg_hidenseek_end"))
	{
		title = "SeeClearly|Fun & Games 1|" + pageName;
	}	
	else if (pageName.match("fg_astig_start") ||
			pageName.match("fg_astig_end"))
	{
		title = "SeeClearly|Fun & Games 2|" + pageName;
	}	
	else if (pageName.match("fg_vision_challenge_start") ||
			pageName.match("fg_vision_challenge_end"))
	{
		title = "SeeClearly|Fun & Games 3|" + pageName;
	}	
	else if (pageName.match("fg_quiz_start") ||
			pageName.match("fg_quiz_end"))
	{
		title = "SeeClearly|Fun & Games 4|" + pageName;
	}		
	else if (pageName.match("sally_blog_popup"))
	{
		title = "SeeClearly|Sally's Blog|" + pageName;
	}	
	else if (pageName.match("acuvue_products1_start") ||
			pageName.match("acuvue_products1_end"))
	{
		title = "SeeClearly|ACUVUE for Astigmatism Products|" + pageName;
	}	
	else if (pageName.match("acuvue_products2_start") ||
			pageName.match("acuvue_products2_end"))
	{
		title = "SeeClearly|ACUVUE for Astigmatism Products|" + pageName;
	}			
	else if (pageName.match("meetexpert_popup"))
	{
		title = "SeeClearly|Meet Our Experts|" + pageName;
	}
	else if (pageName.match("tell_a_friend_start") ||
			pageName.match("tell_a_friend_complete"))
	{
		title = "SeeClearly|Tell a Friend|" + pageName;
	}	
				
  return title;
}


function getTrackHitTitle(pageName,trackingURL)
{
  var title = "";
  var currentURL = trackingURL.toLowerCase();

		
	if (currentURL.match("photogenic.html"))
	{
		title = "AV_Life-Beauty|Photogenic|" + pageName;
	}
	else if (currentURL.match("eyelids.html") ||
			currentURL.match("aw_eye_makeup.html"))
	{
		title = "AV_Life-Beauty|Make_Up|" + pageName;
	}		
	else if (currentURL.match("sitemap.html"))
	{
		title = "Compliance|Footer|" + pageName;
	}
	else
	{
		title = "AV_Life-Health|Main_Page|" + pageName;
	}		
		
  return title;
}


