function popupImageUpload(val1, val2, val3, val4){
	if(val2=='' && document.forms[val3].elements[val4].value!=''){
		val2 = document.forms[val3].elements[val4].value;
	}
	var popupPath = 'admin_upload_picture.php?type='+val1+'&ID='+val2+'&formName='+val3+'&fieldName='+val4+'';
	popupWindow(popupPath, 1, 500, 500);
}

function popupWindow(path, where, hite, wide){
	if (window.event){ 
		window.event.returnValue = false;   
	}
	var width;
	var height;
	var imgWidth;
	var imgHeight;
	
	if (screen.width<wide){
		width=screen.width-20;
		imgWidth=width-10;
		var windowX = (screen.width-width)/2;
	}
	else{
		var windowX = (screen.width-wide)/2;
		width=wide;
	}

	if (screen.height<hite){
		height=screen.height-70;
		imgHeight=height-20;
		var windowY = (screen.height-height)/2-30;
	}
	else{
		var windowY = (screen.height-hite)/2-10;
		height=hite;
	}

	var rand_no = Math.random();
	var i = Math.round(100*Math.random());
	if(screen.height<hite || screen.width<wide){
		var props=window.open(path, i, 'scrollbars=1,toolabars=0,resizable=1,status=0,menubar=0,directories=0,location=0,height='+(hite+30)+', width='+(wide+30));
	}
	else{
		var props=window.open(path, i, 'scrollbars=1,toolabars=0,resizable=1,status=0,menubar=0,directories=0,location=0,height='+(hite+30)+', width='+(wide+30));
	}
	props.moveTo(windowX,windowY);
}


function Display(formname, fieldname){
	fldval = document.forms[formname].elements[fieldname].value;
	
	if(fldval == 'Alcatel'){
		document.getElementById('tab2').style.display = 'none';
		document.getElementById('tab1').style.display = '';
	}
	else if(fldval == 'Avaya'){
		document.getElementById('tab1').style.display = 'none';
		document.getElementById('tab2').style.display = '';
	}else if(fldval =='0'){
		 document.getElementById('tab1').style.display = 'none';
		 document.getElementById('tab2').style.display = 'none';
		}
}


function popupImageUpload(val1, val2, val3, val4){
	if(val2=='' && document.forms[val3].elements[val4].value!=''){
		val2 = document.forms[val3].elements[val4].value;
	}
	var popupPath = 'admin_upload_picture.php?type='+val1+'&ID='+val2+'&formName='+val3+'&fieldName='+val4+'';
	popupWindow(popupPath, 1, 500, 500);
}

function chgTopHdr(id, content){
	parent.document.getElementById(id).innerHTML = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td valign="top" align="left" width="380"><img src="'+content+'" border="0" alt=""></td></tr></table>';
}


function fillUpBillingAddress() {
	if(document.forms['address'].elements['samebilling'].checked==true) {
		document.forms['address'].elements['shipping_name'].value = document.forms['address'].elements['billing_name'].value;
		document.forms['address'].elements['shipping_street_address'].value = document.forms['address'].elements['billing_street_address'].value;
		document.forms['address'].elements['shipping_post_code'].value = document.forms['address'].elements['billing_post_code'].value;
		document.forms['address'].elements['shipping_city'].value = document.forms['address'].elements['billing_city'].value;
		document.forms['address'].elements['shipping_state'].value = document.forms['address'].elements['billing_state'].value;
		/*document.forms['address'].elements['shipping_country'].value = document.forms['address'].elements['billing_country'].value;*/
		document.forms['address'].elements['shipping_email'].value = document.forms['address'].elements['billing_email'].value;
		
	}
	else {
		document.forms['address'].elements['shipping_name'].value = '';
		document.forms['address'].elements['shipping_street_address'].value = '';
		document.forms['address'].elements['shipping_post_code'].value = '';
		document.forms['address'].elements['shipping_city'].value = '';
		document.forms['address'].elements['shipping_state'].value = '';
		document.forms['address'].elements['shipping_email'].value = '';
	}
}

/*function display_option(formname, onchangefieldname, displayid){
	fldval = document.forms[formname].elements[onchangefieldname].value;
	if(onchangefieldname == 'function') {
		if(fldval == 'wedding'){
			document.getElementById(displayid).style.display = '';
		}
		else{
			document.getElementById(displayid).style.display = 'none';
		}
	} 
}*/

function display_option() {
	if(document.forms['address'].elements['function']) {
		if(document.forms['address'].elements['function'].value=='wedding') {
			document.getElementById('wedding_party').style.display = '';
			document.getElementById('bridal_table').style.display = '';
		} else {
			document.getElementById('wedding_party').style.display = 'none';
			document.getElementById('bridal_table').style.display = 'none';
		}
	}
}

function display_option2() {
	if(document.forms['address'].elements['type_of_housing']) {
	
		if((document.forms['address'].elements['type_of_housing'].value=='marquee') || (document.forms['address'].elements['type_of_housing'].value=='pavillion')) {
			document.getElementById('surface_of_housing').style.display = '';
			document.getElementById('silk_lining').style.display = '';
			document.getElementById('fairy_light').style.display = '';
		} else {
			document.getElementById('surface_of_housing').style.display = 'none';
			document.getElementById('silk_lining').style.display = 'none';
			document.getElementById('fairy_light').style.display = 'none';
		}
	}
}

	