﻿var popDialogueDiv = document.getElementById('popDialogueShadow'); //make global for close function
var popDialogueArrow = document.getElementById('dialogueArrow'); //make global for findPos function
var xPos;
var yPos;
var currentItem;
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

window.onresize = moveWindow; //move popup if resized


/**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31;
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30;}
		if (i==2) {this[i] = 29;}
   } 
   return this
}

function isDate(dtStr){ 
	var daysInMonth = DaysArray(12);
	var pos1=dtStr.indexOf(dtCh);
	var pos2=dtStr.indexOf(dtCh,pos1+1);
	var strMonth=dtStr.substring(0,pos1);
	var strDay=dtStr.substring(pos1+1,pos2);
	var strYear=dtStr.substring(pos2+1);
	strYr=strYear;

	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1);
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1);
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1);
	}

	month=parseInt(strMonth);
	day=parseInt(strDay);
	year=parseInt(strYr);

	if (pos1==-1 || pos2==-1){
		return false;
	}
	if (strMonth.length<1 || month<1 || month>12){
		return false;
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		return false;
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		return false;
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		return false;
	}
	return true;
}

function moveWindow() { //check to see if moving is needed first
    if (popDialogueDiv != null && popDialogueDiv.style.display == 'block') {
        findPos(xPos,yPos);
	}   
}
function homePopDialogue(itemID,xPosition,yPosition) //ShowPane (iframe link to show, referring link [cannot be areamap, has to be called from onClick] )
{
	xPos = xPosition;
	yPos = yPosition;
	popDialogueDiv = document.getElementById('popDialogueShadow'); //common popDialogue div
	popDialogueArrow = document.getElementById('dialogueArrow'); //arrow to show
	popDialogueTitle = document.getElementById('dialogueArrow'); //arrow to show
HPUE();//close HPU if open
	arrowTopOffset = 7;
	arrowBottomOffset = -5;

	popDialogueDiv.style.display = 'block'; //show popup win
//show correct ID here
	if (currentItem){//hide current
	 	document.getElementById('pdID'+currentItem).style.display='none';
	}
	document.getElementById('pdID'+itemID).style.display='block';
	currentItem = itemID;		
//end show correct ID here

	findPos(xPos,yPos); //position the popup... need to show it first to determine its height/width
	return false; // this removes the browser history
}

function findPos(xPos,yPos)// find place to draw popdialogue
{
startLocation = document.getElementById('homeContent');
	popDialogueArrow.style.display = 'block';	//show popup arrow
	var curleft = curtop = 0;

	var linkWidth = 75;	

	if (startLocation.offsetParent) { //get homeContent container's position from top/left from page's top
		curleft = startLocation.offsetLeft
		curtop = startLocation.offsetTop;
		while (startLocation = startLocation.offsetParent) {
			curleft += startLocation.offsetLeft
			curtop += startLocation.offsetTop
		}
		curleft -= 24;	//positioning fix
	}

	curleft += xPos; //based math off of flash location
curtop -= (fo.height - yPos); //based math off of flash location

	var xoffSet = -40;	//drop popup -25px left
	var yoffSet = 20;	//drop popup 25px below
	arrowIndent = 30;	//draw the arrow 35px right of the start of the link
	dialoguePadding = 10;
	windowHeight = 0;
	windowWidth = 0;
	if (document.documentElement.innerWidth){ //Mac Safari doesn't understand clientWidth properly and winIE doesn't understand innerHeight
		windowWidth = document.documentElement.innerWidth;
	}
	else {
		//windowWidth = document.body.clientWidth;
		windowWidth =document.documentElement.clientWidth;
	}

	if (window.innerHeight){ //Mac Safari doesn't understand clientheight properly and winIE doesn't understand innerHeight
		windowHeight = window.innerHeight;
	}
	else {
		//windowHeight = document.body.clientHeight;
		windowHeight = document.documentElement.clientHeight;
	}
//*************************************************
	var numAttemps = 4;
	var i=1;
	var foundPos="false";
if (foundPos !="true") {//forward
	do {
		var offSetTry = Math.abs(xoffSet)*i;
		var pos =  curleft + (xoffSet*2) + offSetTry;
		var arrPos = (arrowIndent+dialoguePadding+(linkWidth/2))-(offSetTry+xoffSet);
		if(widthPlacement(pos,arrPos)) {
			i=numAttemps;
			foundPos="true";
		}
		
	i++;
	}
	while (i<numAttemps);
}
if (foundPos !="true") {//backward
	var i=1;
	do {
		var offSetTry = xoffSet*i;
		var pos = curleft-(popDialogueDiv.offsetWidth-(linkWidth-(xoffSet*2)))+(offSetTry+xoffSet)+Math.abs(xoffSet);
		var arrPos = popDialogueDiv.offsetWidth - (arrowIndent+dialoguePadding+(linkWidth/2));
		if(widthPlacement(pos,arrPos)) {
			i=numAttemps;
			foundPos="true";
		}
	
	i++;
	}
	while (i<(numAttemps));
}
if (foundPos !="true") {//just center to screen width
	var pos = (windowWidth - popDialogueDiv.offsetWidth)/2;
	var arrPos = popDialogueDiv.offsetWidth /2;
	widthPlacement(pos,arrPos);
	popDialogueArrow.style.display = 'none'; //hide arrow since its centered
	foundPos="true";
}
//
//Calculate height Position
//
	if ((curtop-document.body.scrollTop+popDialogueDiv.offsetHeight+yoffSet) > windowHeight) { //not enough room to show below link so show above
		popDialogueDiv.style.top = curtop - popDialogueDiv.offsetHeight - 2 +'px';
		popDialogueArrow.className = 'arrowDown';
		popDialogueArrow.style.top =  popDialogueDiv.offsetHeight - arrowTopOffset + 'px'; //set arrow position
	}
	else {
		popDialogueDiv.style.top = curtop + yoffSet +'px'; // show link  below
		popDialogueArrow.className = 'arrowUp';
		popDialogueArrow.style.top = arrowBottomOffset + 'px'; //set arrow position
	}

    toggleSelect('block',popDialogueDiv.style.left,popDialogueDiv.style.top,popDialogueDiv.offsetWidth,popDialogueDiv.offsetHeight);

}

function toggleSelect(displayIframe,x,y,w,h){// IE5&6 shows select items OVER popDialogue, fixed in IE7
	if (parseFloat(navigator.appVersion.split("MSIE")[1]) < 7) { //select box showing error in IE5&6
		var IEselectBoxFix = document.getElementById('IEselectBoxFix');
		IEselectBoxFix.style.left=x;
		IEselectBoxFix.style.top=y;
		IEselectBoxFix.style.display=displayIframe;
		IEselectBoxFix.style.width=w;
		IEselectBoxFix.style.height=h;
	}
	return false;
} 
function widthPlacement(pos, theArrowPos){
	if (pos > (document.body.scrollLeft + dialoguePadding) && (pos + popDialogueDiv.offsetWidth) < (document.body.scrollLeft + windowWidth)) { //show to right of link
		popDialogueDiv.style.left = pos+'px';
		popDialogueArrow.style.left = theArrowPos+'px'; //set arrow position
		return true;
	}else {
		return false;
	}
}
function PopDialogueClose() {
	if(popDialogueDiv){ //make sure it is available b/4 closing
		toggleSelect('none',popDialogueDiv.style.left,popDialogueDiv.style.top,popDialogueDiv.offsetWidth,popDialogueDiv.offsetHeight);
		popDialogueDiv.style.display = 'none'; //hide popup win
		popDialogueArrow.style.display = 'none'; //hide popup win
	}
}
// ---------------------------------------------------------------------------------------------------
// HOMEPOPUP
// ---------------------------------------------------------------------------------------------------
var HPUDiv; //make global for close function
var HPUcover; //make global for close function
var HCDiv; //make global for close function
var HCIDiv; //make global for close function
function HPU(HC, HCI){ // container of 3 to show, item in container to show )
	if (HCDiv){HPUC();}

	HPUDiv = document.getElementById('HPU2'); //common popDialogue div
	HPUcover = document.getElementById('HPUcover'); //white cover over 3 columns
	HCDiv = document.getElementById(HC); //column content
	HCIDiv = document.getElementById(HCI); //specific content to show

	HPUDiv.style.display = 'block'; //show popup win
	HPUcover.style.display = 'block'; //show popup win
	HCDiv.style.display = 'block'; //show popup win
	HCIDiv.style.display = 'block'; //show popup win
	PopDialogueClose(); //close homeDialogue if open
	
	document.getElementById('IEselectBoxFix2').style.display = 'block'; //show popup win
	return false; // this removes the browser history
}
function HPUC() { //clear current HPU
	HCDiv.style.display = 'none'; //hide popup win
	HCIDiv.style.display = 'none'; //hide popup win
}
function HPUE() {
	if (HPUDiv){ //make sure it is available b/4 closing
		HPUcover.style.display = 'none'; //hide popup win
		HCDiv.style.display = 'none'; //hide popup win
		HCIDiv.style.display = 'none'; //hide popup win
		HPUDiv.style.display = 'none'; //hide popup win
		document.getElementById('IEselectBoxFix2').style.display = 'none'; //show popup win
	}
}
// ---------------------------------------------------------------------------------------------------
// SHOW/HIDE the home boxes
//removed 4/1/08
// ---------------------------------------------------------------------------------------------------
// Get Quote boxes

var drpProductCategory = '';
var drpCountryList = '';
var drpDestinationState = '';
var drpStateList = '';
function showGetQuoteForm(theForm) {
	document.getElementById(theForm).style.display = 'inline'; //show getQuoteForm
	if (theForm == 'getQuoteForm2'){
		document.getElementById('getQuoteForm1').className = "getQuoteForm1b";
	}
	return false;
}
function hideGetQuoteForm(theForm) {  

	if (theForm == 'getQuoteForm2' && nonFlash == false && document.getElementById('getQuoteForm2').style.display =='inline'){
		window["myFlashMovie"].TPlay("/quoteB");
	}

	document.getElementById(theForm).style.display = 'none'; //hide getQuoteForm
	document.getElementById('getQuoteForm1').className = "getQuoteForm1a";
	return false;
}

function validateQuote()
{
 if (Page_IsValid)
 {
 	var message = '';
 	
 	var departureDate = document.getElementById("ctl00_pageContent_txtDeptDate").value;
	var returnDate = document.getElementById("ctl00_pageContent_txtRetDate").value;
	var tripDepositDate = document.getElementById("ctl00_pageContent_txtTripDepDate").value;
	var finalTripPaymentDate = txtFinalTripPayDate.value;

 	var getDeptDate = new Date(departureDate);
	var getRetnDate = new Date(returnDate);
	var getTripDepDate = new Date(tripDepositDate);
	var getFinalTripPayDate = new Date(finalTripPaymentDate);

	var today = new Date();
    var month = today.getMonth()+1;
    var year = today.getYear();
    var day = today.getDate();
    var dToday = new Date();
    
	if(day<10){day = "0" + day;}
    if(month<10){month= "0" + month;}
    if(year<1000){year = year + 1900;}     
    
	dToday = new Date(month + "/" + day + "/" + year);
	if (!isDate(departureDate))
	{
		message += "- Please enter a valid departure date. \n \n";
	}
	else if (getDeptDate <= dToday)
	{       
		message = "- Departure date cannot be in the past or today. \n \n";
		document.getElementById("ctl00_pageContent_txtDeptDate").value = "mm/dd/yyyy";		
	}
	
	if (!isDate(returnDate))
	{
		message += "- Please enter a valid return date. \n \n";
	}
	else if (getRetnDate < getDeptDate)
	{
	        message = "- Return date cannot be before departure date. \n \n";
		document.getElementById("ctl00_pageContent_txtRetDate").value = "mm/dd/yyyy";
	}	

	if (!isDate(tripDepositDate))
	{
		message += "- Please enter a valid trip deposit date. \n \n";
	}
	else if (getTripDepDate > dToday)
	{	    
	    message = "- Trip deposit date cannot be in future. \n \n";
	    document.getElementById("ctl00_pageContent_txtTripDepDate").value = "mm/dd/yyyy";	
	} 

	if (!isDate(finalTripPaymentDate))
	{
		message += "- Please enter a valid final trip payment date. \n \n";
	}
	else if (getFinalTripPayDate > dToday && getFinalTripPayDate != 'mm/dd/yyyy')
	{	    
	    message = "- Final trip payment date cannot be in future. \n \n";
	    document.getElementById(txtFinalTripPayDate.id) = "mm/dd/yyyy";	
	}
	
 	getBirthDate = document.getElementById("ctl00_pageContent_txtBirthDate").value;

	if (!validTripCost(document.getElementById("ctl00_pageContent_txtTripCost").value))
	{
		message += "- Please enter trip cost for Traveler #1. Trip Cost cannot be over 999999 \n \n";
	}

	if (!isDate(getBirthDate))
	{
		message += "- Please enter a valid birth date for Traveler #1. \n \n";
	}
	
 	var getBirthDate2 = document.getElementById("ctl00_pageContent_txtBirthDate1").value;
	var tripCost2 = document.getElementById("ctl00_pageContent_txtTripCost1").value;

	if (getBirthDate2 != '' || tripCost2 != '')
	{ 
		if (!isDate(getBirthDate2))
		{
			message += "- Please enter a valid birth date for Traveler #2. \n \n";
		}

		if (!validTripCost(tripCost2))
		{
			message += "- Please enter trip cost for Traveler #2. Trip Cost cannot be over 999999 \n \n";
		}
	}
	
	if (message != '')
	{
		alert('The following item(s) require your attention: \n \n' + message);
		return false
	}
	
    if (document.getElementById("ctl00_pageContent_txtDeptDate").value == 'mm/dd/yyyy' ||
        document.getElementById("ctl00_pageContent_txtRetDate").value == 'mm/dd/yyyy' ||
        document.getElementById("ctl00_pageContent_txtTripDepDate").value == 'mm/dd/yyyy' ||
        document.getElementById("ctl00_pageContent_txtBirthDate").value == '' ||
        document.getElementById("ctl00_pageContent_txtTripCost").value == '')
    {
        return false;
    }
    else
    {
        getProductCategory()
        return true;
    }
 } 
 return false;
}

function validTripCost(value)
{
	return !(value == '' || value >= 1000000 || value < 0);
}

function getProductCategory()
{
    if(drpProductCategory == "PCTDSSTUDYABROAD")
    {
        var getDeptDate = new Date(document.getElementById("ctl00_pageContent_txtDeptDate").value);
        var getRetnDate = new Date(document.getElementById("ctl00_pageContent_txtRetDate").value);
        var tripLength = (getRetnDate - getDeptDate)/86400000 //86400000 = number of milliseconds in 1 day.
        
        if(tripLength >= 1 && tripLength <= 14)
        {
            drpProductCategory = "PCTDSSTUDYABROAD";
        }

	    if(tripLength >= 15 && tripLength <= 30)
        { 
            drpProductCategory = "PCTDSSTUDYABROAD15";
        }
        
        if(tripLength > 30)
        {
            drpProductCategory = "PCTDSSTUDYABROAD30";  	        
        }     
        	        
        drpCountryList = document.getElementById("ctl00_pageContent_drpCountryList").value;
        drpStateList = document.getElementById("ctl00_pageContent_drpStateList").value;   
        
        document.getElementById('ctl00_pageContent_theURL').value =__altUtmLinker(TRAVEL_GUARD_PURCHASE_DOMAIN + "/tgi2/pct/TripInfoTGDirect.aspx",0,1) + isUrchinEnabled + "br=tgdirect&pc=" + drpProductCategory + "&cn=" + drpCountryList + "&st=" + drpStateList;
        document.getElementById('ctl00_pageContent_txtAddlTravl').value = __altUtmLinker(TRAVEL_GUARD_PURCHASE_DOMAIN + "/tgi2/pct/default.aspx",0,1) + isUrchinEnabled + "br=tgdirect&pc=" + drpProductCategory + "&cn=" + drpCountryList + "&st=" + drpStateList; 
    }
    return true;
}

function validateGetQuote() {

	var message = '';
	//check to see if ready to show trip info
	if (drpProductCategory == '')
	{
		message = "- Please select the type of trip  you are taking. \n \n";
	}
	if (drpCountryList == '')
	{
		message += "- Please select your destination country. \n \n";
	}
	
	if ((drpCountryList == '1' || drpCountryList == '2') && drpDestinationState == '')
	{
			message += "- Please select your destination state/providence. \n \n";
	}
	if (drpStateList == '')
	{
		message += "- Please select your state of residency.";
	}
	
	if (message == '')
	{
	    // Validate that State Selected is allow to sell products
	    if (ValidState() == true)
	    {
		    if (nonFlash == true)
		    {
		        document.getElementById('getQuoteForm2').className = "getQuoteForm2c";
		    }
		    return true;
		}
		else
		{
		    return false;
		}
	}
	else
	{
		alert('The following item(s) require your attention: \n \n' + message);
		return false;
	}
}

// Added - Larissa Munz - 2/11/2009 - 3166-6 - Restrict sales on TGDirect to Certain States
// Added code to restrict purchase on TGDirect for configurable states.
function ValidState()
{
    var isValidState = true;
    var SelectedState = document.getElementById("ctl00_pageContent_drpStateList").options[document.getElementById("ctl00_pageContent_drpStateList").selectedIndex].text

    // Get Invalid State list
    // 3769 - Larissa Munz - Removed Pennsylvania
    // 3805 - Larissa Munz - Removed Indiana
    // 4033 - Corey Kruzicki - Removed Connecticut; 
    var InvalidStates = "New Hampshire;Puerto Rico";//Application["InvalidStatesTgDirect"];
    // Turn String to Array of States
    var stateList = InvalidStates.split(';');

    // Find if selected state is part of Invalid State List
    for (var index=0; index<= stateList.length - 1; index++)
    {
        if (SelectedState.toLowerCase() == stateList[index].toLowerCase())
        {
            isValidState = false;
            break;
        }
    }

    // If on direct & invalid State was selected show Error Message
    if (isValidState == false)
    { 
        alert("Travel Guard products are temporarily unavailable on this site for your state. We apologize for the inconvenience. Please visit Travelguard.com for valuable travel insurance coverage for future trips.");//Application["InvalidStatesMessage"]);
	    return false;
    }
    else
    {
        return true;
    }
}

function btnContinue() { 
 	//validate 1st
	drpProductCategory = document.getElementById("drpProductCategory").value;
	drpCountryList = document.getElementById("ctl00_pageContent_drpCountryList").value;
	if (drpCountryList == 1 || drpCountryList == 2) { //make sure its usable
		drpDestinationState = document.getElementById("ctl00_pageContent_drpDestinationState" + drpCountryList).value;
	}
	drpStateList = document.getElementById("ctl00_pageContent_drpStateList").value;
	
	if (validateGetQuote()){
		
		if (nonFlash == true){document.getElementById('getQuoteForm2').className = "getQuoteForm2c";}
		
		//hide any current windows
		PopDialogueClose();
		
		if (nonFlash == false){
			window["myFlashMovie"].TPlay("/quoteB");
		}
		
		//show tripInfo
		if (nonFlash == true){
			showGetQuoteForm("getQuoteForm2");
		}
		
		//build the urchin tracking AND 1st container values into input box
		document.getElementById('ctl00_pageContent_theURL').value =__altUtmLinker(TRAVEL_GUARD_PURCHASE_DOMAIN + "/tgi2/pct/TripInfoTGDirect.aspx",0,1) + isUrchinEnabled + "br=tgdirect&pc=" + drpProductCategory + "&cn=" + drpCountryList + "&st=" + drpStateList;	
		document.getElementById('ctl00_pageContent_txtAddlTravl').value = __altUtmLinker(TRAVEL_GUARD_PURCHASE_DOMAIN + "/tgi2/pct/default.aspx",0,1) + isUrchinEnabled + "br=tgdirect&pc=" + drpProductCategory + "&cn=" + drpCountryList + "&st=" + drpStateList;	
	}
	return false;
}

function validateTripType() {
	if(document.getElementById("drpProductCategory").value == 'PCTDSFREQTRAVELER'){
	//hide questions
		document.getElementById("drpCountryListDiv").style.display = 'none';
		if (document.getElementById("ctl00_pageContent_drpCountryList").value == ''){
			document.getElementById("ctl00_pageContent_drpCountryList").value = '00'; //set it to 'unlisted' for pct usage
		}
	}else {
		document.getElementById("drpCountryListDiv").style.display = 'block';
		validateDestinationCountry();
	}
	hideGetQuoteForm('getQuoteForm2');
	return false;
}

function validateDestinationCountry() {
	test = document.getElementById("ctl00_pageContent_drpCountryList").value;
	document.getElementById("drpDestinationStateDiv1").style.display ='none';
	document.getElementById("drpDestinationStateDiv2").style.display ='none';
	if (test == 1 || test == 2) {//show ca/us destination
		document.getElementById("drpDestinationStateDiv" + test).style.display = 'block';
	}
	hideGetQuoteForm('getQuoteForm2');
	return false;
}
function validateStateDiv() {
	if (document.getElementById("ctl00_pageContent_drpStateList").value != ''){
		document.getElementById('stateDrop').style.display = 'inline';
	}else {
	document.getElementById("ctl00_pageContent_txtZipCode").value = '';
	}
}
function init(){ //this is cleared by inlined call on homepage
	validateStateDiv();	//show state residency IF chosen
	validateTripType(); //reset destination country/states
	return false;
}

function getQueryStrings(url) 
{ 
    var argList = new Object();

    if(url.length > 1)
    {
        var urlParms = url.substring(1);
        var argPairs = urlParms.split('&');

        for(var i = 0; i < argPairs.length; i++) {
            var pos = argPairs[i].indexOf('=')

            if(pos == -1)
                continue;
            else {
                var argName = argPairs[i].substring(0, pos);
                var argVal = argPairs[i].substring(pos + 1);
                
                if(argVal.indexOf('+') != -1)
                    argVal = argVal.replace(/\+/g, ' ');

                argList[argName] = unescape(argVal);              
            }
        }
    }    
    return argList;
}
function __altUtmLinker(l,h,ret) {
	 if (!_ulink) return;
	 var p,k,a="-",b="-",c="-",x="-",z="-",v="-";
	 var dc=_ubd.cookie;
	 var lnk;
	 if (!l || l=="") return;
	 var iq = l.indexOf("?");
	 var ih = l.indexOf("#");
	 if (dc) {
		  a=_uES(_uGC(dc,"__utma="+_udh,";"));
		  b=_uES(_uGC(dc,"__utmb="+_udh,";"));
		  c=_uES(_uGC(dc,"__utmc="+_udh,";"));
		  x=_uES(_uGC(dc,"__utmx="+_udh,";"));
		  z=_uES(_uGC(dc,"__utmz="+_udh,";"));
		  v=_uES(_uGC(dc,"__utmv="+_udh,";"));
		  k=(_uHash(a+b+c+x+z+v)*1)+(_udh*1);
		  p="__utma="+a+"&__utmb="+b+"&__utmc="+c+"&__utmx="+x+"&__utmz="+z+"&__utmv="+v+"&__utmk="+k;
	 }
	 if (p) {
		  if (h && ih>-1) return;
		  if (h) { lnk=l+"#"+p; }
		  else {
		   if (iq==-1 && ih==-1) lnk=l+"?"+p;
		   else if (ih==-1) lnk=l+"&"+p;
		   else if (iq==-1) lnk=l.substring(0,ih-1)+"?"+p+l.substring(ih);
		   else lnk=l.substring(0,ih-1)+"&"+p+l.substring(ih);
		  }
	 } else { lnk=l; }
	
	 if (ret) return lnk;
	 _udl.href=lnk;

} 