var contarr=new Array();

contarr=["Bahrain","Egypt","Jordan","Kuwait","Lebanon","Oman","Qatar","Saudi Arabia","Syria","United Arab Emirates","Yemen","-----------------","USA","United Kingdom","Canada","France","Germany","Italy","Spain","Sweden","-----------------","Afghanistan","Albania","Algeria","Andorra","Angola","Anguilla","Antigua & Barbuda","Argentina","Armenia","Aruba","Australia","Austria","Azerbaijan","Bahamas","Bangladesh","Barbados","Belarus","Belgium","Belize","Benin","Bermuda","Bhutan","Bolivia","Bosnia","Botswana","Bougainville","Brazil","British Virgin Islands","Brunei","Bulgaria","Burkina Faso","Burundi","Cambodia","Cameroon","Cape Verde","Cayman Islands","Central African Rep.","Chad","Channel Islands","Chile","China","Christmas Island","Colombia","Comoros","Congo","Cook Islands","Costa Rica","Croatia","Cuba","Cyprus","Czech Republic","Denmark","Djibouti","Dominica","Dominican Republic","Ecuador","El Salvador","Equatorial Guinea","Eritrea","Estonia","Ethiopia","Faeroe Islands","Falkland Islands","Fiji","Finland","French Guiana","French Polynesia","Gabon","Gambia","Georgia","Ghana","Gibraltar","Greece","Greenland","Grenada","Guadeloupe","Guatemala","Guinea-Bissau","Guyana","Haiti","Holy See","Honduras","Hong Kong","Hungary","Iceland","India","Indonesia","Iran","Iraq","Ireland","Isle of Man","Israel","Ivory Coast","Jamaica","Japan","Johnston Island","Kazakhstan","Kenya","Kirghizia","Kiribati","Laos","Latvia","Lesotho","Liberia","Libya","Liechtenstein","Lithuania","Luxembourg","Macao","Macedonia","Madagascar","Malawi","Malaysia","Maldives","Mali","Malta","Martinique","Mauritania","Mauritius","Mayotte","Mexico","Micronesia","Midway Islands","Moldavia","Monaco","Mongolia","Montenegro","Montserrat","Morocco","Mozambique","Myanmar","Namibia","Nauru","Nepal","Netherlands","Netherlands Antilles","New Caledonia","New Zealand","Nicaragua","Niger","Nigeria","Niue Island","Norfolk Island","North Cyprus","North Korea","Norway","Pakistan","Palestine","Panama","Papua New Guinea","Paraguay","Peru","Philippines","Pitcairn Islands","Poland","Portugal","Queen Maud Land","Reunion","Romania","Ross Dependency","Russia","Rwanda","Sahara","Saint Helena","Saint Lucia","Samoa","San Marino","Senegal","Serbia","Seychelles","Sierra Leone","Singapore","Slovakia","Slovenia","Solomon Islands","Somalia","Somaliland","South Africa","South Korea","Spanish North Africa","Sri Lanka","Sudan","Suriname","Swaziland","Switzerland","Taiwan","Tajikistan","Tanzania","Thailand","Timor","Togo","Tokelau Islands","Tonga","Trinidad & Tobago","Tunisia","Turkey","Turkmenistan","Tuvalu","Uganda","Ukraine","Uruguay","Uzbekistan","Vanuatu","Vatican City State","Venezuela","Vietnam","Wake Island","Zaire","Zambia","Zimbabwe"]

function congen(cnt) {
	document.write('<option value="'+cnt+'">'+cnt+'</option>');
}

function daygen(d,curr) {
	if(curr==d) {
		document.write('<option value="'+d+'" selected>'+d+'</option>');
	} 
	else {
		document.write('<option value="'+d+'">'+d+'</option>');
	}
}

//for Vpop
function jspopUp(id,tbl) {
	window.open('vpop.php?id='+id+'&tbl='+tbl, 'Info', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=0, width=350, height=400, left = 300, top = 200');
}

function popSite(site) {
	window.open(site);
}

var m = new Array();
m[1]="January";
m[2]="February";
m[3]="March";
m[4]="April";
m[5]="May";
m[6]="June";
m[7]="July";
m[8]="August";
m[9]="September";
m[10]="October";
m[11]="November";
m[12]="December";

function monthgen(mon,cr) {
	if(cr==mon) {
		document.write('<option value="'+mon+'" selected>'+m[mon]+'</option>');
	}
	else {
		document.write('<option value="'+mon+'">'+m[mon]+'</option>');
	}
}

function goback() {
	window.history.go(-1);
}


//Functions to generate the select list and save selections
function moveOver(frm,fld) {
	var boxLength = eval("document."+frm+".choiceBox.length");
	var selectedItem = eval("document."+frm+"."+ fld +".selectedIndex");
	var selectedText = eval("document."+frm+"."+ fld +".options[selectedItem].text");
	var selectedValue = eval("document."+frm+"."+ fld +".options[selectedItem].value");
	var i;
	var isNew = true;
	if (boxLength != 0) {
		for (i = 0; i < boxLength; i++) {
			thisitem = eval("document."+frm+".choiceBox.options[i].text");
			if (thisitem == selectedText) {
				isNew = false;
				break;
			}
		}
	}
	if (isNew) {
		newoption = new Option(selectedText, selectedValue, false, false);
		document.modarticle.choiceBox.options[boxLength] = newoption;
	}
	var s2 = eval("document."+frm+"."+ fld +".selectedIndex");
	s2=-1;
	vendselect = saveMe(frm);
}


function removeMe(frm) {
	var boxLength = eval("document."+frm+".choiceBox.length");
	arrSelected = new Array();
	var count = 0;
	for (i = 0; i < boxLength; i++) {
		if (eval("document."+frm+".choiceBox.options[i].selected")) {
			arrSelected[count] = eval("document."+frm+".choiceBox.options[i].value");
		}
	count++;
	}
	var x;
	for (i = 0; i < boxLength; i++) {
		for (x = 0; x < arrSelected.length; x++) {
			if (eval("document."+frm+".choiceBox.options[i].value") == arrSelected[x]) {
				document.modarticle.choiceBox.options[i] = null;
			}
		}
		boxLength = eval("document."+frm+".choiceBox.length");
	}
	vendselect = saveMe(frm);
}


function saveMe(frm) {
	var strValues = "|";
	var boxLength = eval("document."+frm+".choiceBox.length");
	var count = 0;
	if (boxLength != 0) {
		for (i = 0; i < boxLength; i++) {
			strValues = strValues + eval("document."+frm+".choiceBox.options[i].value") + "|" ;
			count++;
		}
	}
	if (strValues.length == 0) {
		//alert("You have not made any selections");
	}
	else {
		//alert("Here are the values you've selected:\r\n" + strValues);
	}
	document.modarticle.reference.value = strValues;
	document.modarticle.chkact.value = "1";
	//alert(document.reseller_frm.vendor.value);
}

// set events/promotions form action

function setEPFormOpt() {
	wForm = document.srh_frm1;
	onList = wForm.stopt;
	offList = wForm.cat;
	if (offList.options[offList.selectedIndex].value == "" && onList.options[onList.selectedIndex].value != "") {
		document.getElementById('srchOpts').style.visibility = "visible";
	}
	else {
		document.getElementById('srchOpts').style.visibility = "hidden";
	}
}

////////Functions to generate the second select list and save selections
function moveOver2(frm,fld)
{
	var boxLength = eval("document."+frm+".choiceBox2.length");
	var selectedItem = eval("document."+frm+"."+ fld +".selectedIndex");
	var selectedText = eval("document."+frm+"."+ fld +".options[selectedItem].text");
	var selectedValue = eval("document."+frm+"."+ fld +".options[selectedItem].value");
	var i;
	var isNew = true;
	if (boxLength != 0) {
		for (i = 0; i < boxLength; i++) {
			thisitem = eval("document."+frm+".choiceBox2.options[i].text");
			if (thisitem == selectedText) {
				isNew = false;
				break;
			}
		}
	}
	if (isNew) {
		newoption = new Option(selectedText, selectedValue, false, false);
		document.modarticle.choiceBox2.options[boxLength] = newoption;
	}
	var s2 = eval("document."+frm+"."+ fld +".selectedIndex");
	s2=-1;
	vendselect2 = saveMe2(frm);
}


function removeMe2(frm) {
	var boxLength = eval("document."+frm+".choiceBox2.length");
	arrSelected = new Array();
	var count = 0;
	for (i = 0; i < boxLength; i++) {
		if (eval("document."+frm+".choiceBox2.options[i].selected")) {
			arrSelected[count] = eval("document."+frm+".choiceBox2.options[i].value");
		}
		count++;
	}
	var x;
	for (i = 0; i < boxLength; i++) {
		for (x = 0; x < arrSelected.length; x++) {
			if (eval("document."+frm+".choiceBox2.options[i].value") == arrSelected[x]) {
				document.modarticle.choiceBox2.options[i] = null;
			}
		}
		boxLength = eval("document."+frm+".choiceBox2.length");
	}
	vendselect2 = saveMe2(frm);
}


function saveMe2(frm) {
	var strValues = "|";
	var boxLength = eval("document."+frm+".choiceBox2.length");
	var count = 0;
	if (boxLength != 0) {
		for (i = 0; i < boxLength; i++) {
			strValues = strValues + eval("document."+frm+".choiceBox2.options[i].value") + "|" ;
			count++;
		}
	}
	if (strValues.length == 0) {
		//alert("You have not made any selections");
	}
	else {
		//alert("Here are the values you've selected:\r\n" + strValues);
	}
	document.modarticle.reference2.value = strValues;
	document.modarticle.chkact2.value = "1";
	//alert(document.reseller_frm.vendor.value);
}

function DoDelete(c,t){
	if (confirm("Are you sure you want to permanently delete this outlet / review / feature from the list?")) {
		window.location = "/manage/delrow.php?id=" + c + "&tbl=" + t;
	}
}
