//this function is uesd in country profile  
function CheckCountrySelected(form_Id, defaultvalue, sitecountrycode) {

	var selected = document.getElementById(form_Id).elements["country"].options[document
			.getElementById(form_Id).elements["country"].selectedIndex].value;

	if (defaultvalue == selected) {
		//alert(" not selected any thing"+selected);
		return false;
	} else {

		if (selected.indexOf(sitecountrycode) >= 0) {

			//if the country is selected in dropdown is 
			//same as country of site 
			//open the link of country profile in same window

			return true;
		}
		//start changes by/suresh 
		//if link is external ,open  new window with external link and return false
		else if (selected.indexOf("http") >= 0
				|| selected.indexOf("https") >= 0) {

			window.open(selected, 'DHL');
			return false;
		} else {
			//open internal link in same window// this logic is already present 
			//Linklistdropdownjsp

			return true;
		}
	}
}

/// this function is used in country selector
function CheckCountrySelector(formId, defaultvalue, isgloballist,
		sitecountrycode) {

	var globallistpresent = isgloballist;
	var trueflag = "true";

	var selected = document.getElementById(formId).elements["country"].options[document
			.getElementById(formId).elements["country"].selectedIndex].value;
	if (defaultvalue == selected) {
		//alert(" not selected any thing"+defaultvalue);
		return false;
	} else {
		///start changes by suresh
		if (globallistpresent == trueflag) {
			//alert("list is global normal flow");
			//open all the URL in same window  for "global_list" as per the 
			//ticket requirment DHL-1973
			window.open(selected, "_parent");
			return false;
		} else {
			if (selected.indexOf(sitecountrycode) >= 0) {
				//if selected list is other than " gloabl_locator"
				//then if country selected is same as country of site 
				//open url in same window 
				window.open(selected, "_parent");
				return false;
			}

			else if (selected.indexOf("http") >= 0
					|| selected.indexOf("https") >= 0) {

				//if country selected is diffrent then 
				//noraml flow /since normol-flow open all the url in new window  
				window.open(selected, "DHL");
				return false;
			} else {
				// if any case is not covered 
				//then open URL in new  window as normal flow
				return true;
			}

		}

	}
}

function checklistselected(formID, id, defaultvalue) {

	//var selected = document.linklist_dropdown_form.elements[id].options[document.linklist_dropdown_form.elements[id].selectedIndex].value;
	//alert(" form id "+formID);
	var selected = document.getElementById(formID).elements[id].options[document
			.getElementById(formID).elements[id].selectedIndex].value;
	if (defaultvalue == selected) {
		//alert(" not selected any thing"+defaultvalue);
		return false;
	} else {

		if (selected.indexOf("INTERNALURL~") >= 0) {

			var raw = selected.split("~");
			var url = raw[1];
			//since this  url belongs to same site 
			//will be opened in same window

			window.open(url, "_parent");
			return false;

		}

		//start changes by/suresh 
		//if link is external ,open  new window with external link and return false
		else if (selected.indexOf("http") >= 0
				|| selected.indexOf("https") >= 0) {

			window.open(selected, 'DHL');
			return false;
		} else {
			//open internal link in same window// this logic is already present 
			//Linklistdropdownjsp

			return true;
		}
	}
}
