// JavaScript Document
var root
//root = 'http://www.formasiabooks.com/'
root = 'http://www.hong-kong-web-design.com/clients/formasia/'


/////////////// tinymce editor
tinyMCE.init({
	mode : "textareas",
	theme : "advanced",


	plugins : "safari,style,table,advimage,advlink,inlinepopups,preview,media,contextmenu,paste,noneditable,nonbreaking,xhtmlxtras,ibrowser",

	// Theme options
	theme_advanced_buttons1 : "bold,italic,underline,|,styleselect,formatselect,ibrowser",
	theme_advanced_buttons2 : "pasteword,|,removeformat,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,image,|,code",
	//theme_advanced_buttons2 : "pasteword,|,removeformat,|,undo,redo,|,link,unlink,anchor,image",
	theme_advanced_buttons3 : "",
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
	theme_advanced_statusbar_location : "bottom",
	theme_advanced_resizing : false,
	
	theme_advanced_blockformats : "p,h1,h3",
	theme_advanced_styles : "Image Left=imgFloatLeft;Image Right=imgFloatRight",
	
	document_base_url : root,
	relative_urls : false,
	remove_script_host : false,	
	
	// Example content CSS
	content_css : root + 'css/tiny.css'
	
});

/////////////// other
function msg(loc) {
    if(confirm("Are you sure you want to delete?"))
    {
        location = loc;
    }
}

function goback(loc) {
    location = loc;
}

function ValidateForm(){
	var categoryID=document.editorForm.category

	if ((categoryID.value==null)||(categoryID.value=="")){
		alert("Please choose a category")
		categoryID.focus()
		return false
	}

	return true
}
function validateCartForm(){
	var fnameID=document.cartFrm.firstname
	var lnameID=document.cartFrm.lastname
	var addID1=document.cartFrm.address1
	var addID2=document.cartFrm.address2
	var cityID=document.cartFrm.city
	var stateID=document.cartFrm.state
	var zipID=document.cartFrm.zip
	var countryID=document.cartFrm.countryCode
	
	if ((fnameID.value==null)||(fnameID.value=="")){
		alert("Please enter your first name")
		fnameID.focus()
		return false
	}
	
	if ((lnameID.value==null)||(lnameID.value=="")){
		alert("Please enter your last name")
		lnameID.focus()
		return false
	}
	
	if ((addID1.value==null)||(addID1.value=="")){
		alert("Please enter your shipping address, Address 1")
		addID1.focus()
		return false
	}	
	
	if ((countryID.value == "HK")||(countryID.value == "IT")) { 
		if ((addID2.value==null)||(addID2.value=="")){
			alert("Please enter your shipping address, Address 2")
			addID2.focus()
			return false
		}
	}
	
	if ((cityID.value==null)||(cityID.value=="")){
		alert("Please enter your town/city")
		cityID.focus()
		return false
	}	
	
	if ((countryID.value != "SG")&&(countryID.value != "DE")&&(countryID.value != "FR")&&(countryID.value != "NL")&&(countryID.value != "AT")&&(countryID.value != "CH")){
		if ((stateID.value==null)||(stateID.value=="")){
			alert("Please enter your state/county/province/region")
			stateID.focus()
			return false
		}
	}
	
	if ((zipID.value==null)||(zipID.value=="")){
		alert("Please enter your zip/postal code")
		zipID.focus()
		return false
	}
	
	return true
 
} 
