<!-- common.js javascript functions for mybes.com -->

// When adding banner, one parameter "i" in the Timer() must also changed 
i = 3 // Number of banners that you have
banner1 = new Image();
banner1.src = "images/anibanner2.gif";
banner2 = new Image();
banner2.src = "images/anibanner1.gif";
banner3 = new Image();
banner3.src = "images/anibanner3.gif";

links = new Array
links[1] = "http://www.myposbox.com/free_submission.htm"
links[2] = "http://www.myposbox.com"
links[3] = "http://www.mybes.com/payment.php"

function randombanner(){
	var randomnumber = Math.random();
	i = Math.round( (i - 1) * randomnumber) + 1;
	document.banner.src = eval("banner" + i + ".src");
}

function startTime(){

        var time= new Date();
        hours= time.getHours();
        mins= time.getMinutes();
        secs= time.getSeconds();
        closeTime=hours*3600+mins*60+secs;
        closeTime+=10;   
        Timer();

}

function Timer(){
        var time= new Date();
        hours= time.getHours();
        mins= time.getMinutes();
        secs= time.getSeconds();
        curTime=hours*3600+mins*60+secs
        if (curTime>=closeTime){
                if (i < 3){
                        i++;
                        document.banner.src = eval("banner" + i + ".src");
                }
                else{
                        i = 1;
                        document.banner.src = eval("banner" + i + ".src");
                }
                startTime();
        }
        else{
                window.setTimeout("Timer()",1000)}

}

function clickLink(){
        top.location = links[i]
}

function display(txt) {
         self.status = txt
}

function checkdomain() {
field=document.myform
if(field.registerdomain[0].checked) {
	field.freedomaintoregister.style.visibility="VISIBLE";
	field.domaintoregister.style.visibility="HIDDEN";
	field.freedomaintoregister.focus();
} else {
	field.domaintoregister.style.visibility="VISIBLE";
	field.freedomaintoregister.style.visibility="HIDDEN";
	field.domaintoregister.focus();
}
calculatetotal();
}

function checkcontent() {
field=document.myform

if(field.suggestnumofpageforme.checked) {
	for(var i=0;i<11;++i) {
		field.content[i].style.visibility="HIDDEN";
		field.content[i].checked=false;
	}
	field.numofproductpage.style.visibility="HIDDEN";
	field.otherspec.style.visibility="HIDDEN";
} else {
	for(var i=0;i<11;++i) {
		field.content[i].style.visibility="VISIBLE";
	}
	if(field.content[10].checked) {
		field.otherspec.style.visibility="VISIBLE";
		field.otherspec.value="";
		field.otherspec.focus();
	} else {
		field.otherspec.style.visibility="HIDDEN";
	}
}
updatenumofpage();
}

function checkproductcontent() {
field=document.myform
productpagetoadd = 0;
if(field.content[0].checked) {
	field.numofproductpage.value=1;
	field.numofproductpage.style.visibility="VISIBLE";
	field.numofproductpage.focus();
} else {
	field.numofproductpage.style.visibility="HIDDEN";
	productpagetoadd=0;
}
updatenumofpage();
}

function updatenumofpage() {
field=document.myform
productpagetoadd = 0;
otherpagetoadd = 0;
homepage = 1;
if(field.suggestnumofpageforme.checked) {
	productpagetoadd=0;
	otherpagetoadd=0;
} else {
	if(field.content[0].checked) {
		if((field.numofproductpage.value)>0) {
			productpagetoadd=field.numofproductpage.value
		    totalnumofproductpage=productpagetoadd*1+otherpagetoadd*1+homepage
		} else {
			productpage=1;
			totalnumofproductpage=productpagetoadd*1+otherpagetoadd*1+homepage
		}
	}
	for(var i=1;i<11;++i) {
		if(field.content[i].checked) {
			++otherpagetoadd;
		}
	}
}
totalnumofproductpage=productpagetoadd*1+otherpagetoadd*1+homepage
field.designpages.value=totalnumofproductpage
calculatetotal();
}

function checksitelocation() {
field=document.myform
if(field.sitelocation[0].checked) {
	field.webaddress.style.visibility="HIDDEN";
}
if(field.sitelocation[1].checked) {
	field.webaddress.style.visibility="VISIBLE";
	field.webaddress.focus();
}
}

function checkaddspace() {
field=document.myform
if(field.addspace[0].checked) {
	field.spacerequired.style.visibility="HIDDEN";
}
if(field.addspace[1].checked) {
	field.spacerequired.style.visibility="VISIBLE";
	field.spacerequired.focus();
}
calculatetotal();
}

function checkaddbandwidth() {

field=document.myform
if(field.addbandwidth[0].checked) {
	field.bandwidthrequired.style.visibility="HIDDEN";
}
if(field.addbandwidth[1].checked) {
	field.bandwidthrequired.style.visibility="VISIBLE";
	field.bandwidthrequired.focus();
}
calculatetotal();
}


function processform() {
missinginfo = "";
field=document.myform

if (field.domaintohost) {
	if (field.domaintohost.value == "") {
	    missinginfo += "\n     -  Please Specify Domain to Host";
	}
}

if(field.Hosting_Plan) {
	if(field.Hosting_Plan[0].selected) {
	    missinginfo += "\n     -  Please select a Hosting Plan";
	}
}

if (field.SMNusername) {
	if (field.SMNusername.value == "") {
	    missinginfo += "\n     -  Please Specify your current FTP username.";
	}
}

if (field.SMNpassword) {
	if (field.SMNpassword.value == "") {
	    missinginfo += "\n     -  Please Specify your current FTP password.";
	}
}

if(field.registerdomain) {
	if(field.registerdomain[0].checked) {
		if (field.freedomaintoregister.value == ""){
			 missinginfo += "\n     -  key in free Domain to Register";
		}
	}
	if(field.registerdomain[1].checked) {
		if ((field.domaintoregister.value == "") || (field.domaintoregister.value.indexOf(".") == -1)){
			 missinginfo += "\n     -  key in Domain to Register";
		}
	}
}

if((field.Inktomi) || (field.Fast) || (field.Ask)) {
	if(!((field.Inktomi.checked) || (field.Fast.checked) || (field.Ask.checked))) {
		missinginfo += "\n     -  Select a submission plan";
	}
}

if (field.url_to_submit) {
	if (field.url_to_submit.value == "") {
	    missinginfo += "\n     -  Please specify URL to submit";
	}
}

if (field.domain_to_use) {
	if (field.domain_to_use.value == "") {
	    missinginfo += "\n     -  Your Domain Name to use";
	}
}

if (field.name) {
	if (field.name.value == "") {
	    missinginfo += "\n     -  Your Full Name";
	}
}

if (field.firstname) {
	if (field.firstname.value == "") {
	    missinginfo += "\n     -  Your First Name";
	}
}

if (field.lastname) {
	if (field.lastname.value == "") {
	    missinginfo += "\n     -  Your Last Name";
	}
}

if (field.company) {
	if (field.company.value == "") {
	    missinginfo += "\n     -  Your Company Name";
	}
}

if (field.companyaddress) {
	if (field.companyaddress.value == "") {
	    missinginfo += "\n     -  Your Company Address";
	}
}

if (field.address) {
	if (field.address.value == "") {
		missinginfo += "\n     -  Address";
	}
}

if (field.city) {
	if (field.city.value == "") {
		missinginfo += "\n     -  City";
	}
}

if (field.state) {
	if ((field.state.value == "NIL") || (field.state.value == "")) {
		missinginfo += "\n     -  State";
	}
}

if (field.postcode) {
	if (field.postcode.value == "") {
		missinginfo += "\n     -  Postcode";
	}
}

if (field.country) {
	if (field.country.value == "") {
		missinginfo += "\n     -  Country";
	}
}

if (field.phone) {
	if (field.phone.value == "") {
	    missinginfo += "\n     -  Phone Number";
	}
}

if (field.email) {
	if ((field.email.value == "") || (field.email.value.indexOf('@') == -1) ||
		(field.email.value.indexOf('.') == -1)) {
		 missinginfo += "\n     -  Email Address";
	}
}

if (field.web_design) {
	if((field.web_design.checked) || (field.positioning.checked)) {
		if (field.description.value == "") {
		    missinginfo += "\n     -  Business description";
		}
		if (field.product.value == "") {
		    missinginfo += "\n     -  Your products/services/brands";
		}
	}
}
	
if (field.enquiry) {
	if (field.enquiry.value == "") {
		missinginfo += "\n     -  Please specify your enquiry.";
	}
}

if (field.domain_register) {
	if(field.domain_register.checked) {
		if ((field.domaintoregister.value == "") ||  (field.domaintoregister.value.indexOf(".") == -1)) {
			 missinginfo += "\n     -  Domain to Register";
		}
	}
}

if (field.sitelocation) {
	if(field.sitelocation[1].checked) {
		if ((field.webaddress.value == "") ||  (field.webaddress.value.indexOf(".") == -1)) {
			 missinginfo += "\n     -  Your Current Site Address";
		}
	}
}
if (field.positioning) {
	if((field.positioning.checked) && (field.page_to_submit)) {
		if (field.page_to_submit.value == "") {
		    missinginfo += "\n     -  URL of web page to submit";
		}
	}
}

displaymissingmessage()
}

function displaymissingmessage() {
if (missinginfo != "") {
missinginfo ="_______________________________\n" +
"The field(s) below incorrect or not filled:\n" +
missinginfo + "\n_____________________________" +
"\nPlease re-enter and submit again!";
alert(missinginfo);
}
else {
document.myform.submit()
}
}

function StartSearch(keywords) {

if (document.searchform.engine.value == "cari") {
out = " "; // replace this character
add = "%20"; // with this character for Cari
temp = "" + keywords; // temporary holder

	if (temp.indexOf(out)>-1) { // if no spaces found , no replacement done
		while (temp.indexOf(out)>-1) { 
		pos = temp.indexOf(out);
		temp = "http://search3.cari.com.my/newlinks/searchlink.php?Word=" + (temp.substring(0, pos) + add + 
temp.substring((pos + out.length), temp.length)) + "&orand=and";
		}
	} else {
		temp = "http://search3.cari.com.my/newlinks/searchlink.php?Word=" + keywords + "&orand=and";
	}
}

if (document.searchform.engine.value == "catcha") {
out = " "; // replace this character
add = "+"; // with this character for Cari
temp = "" + keywords; // temporary holder

	if (temp.indexOf(out)<1) { // if no spaces found , no replacement done
		temp = "http://search.catcha.com.my/cgi-bin/l/search.cgi?wh=Malaysia&query=" + keywords + "&submit=Search";
	} else {
		while (temp.indexOf(out)>-1) { 
		pos = temp.indexOf(out);
		temp = "http://search.catcha.com.my/cgi-bin/l/search.cgi?wh=Malaysia&query=" + (temp.substring(0, pos) + add + 
temp.substring((pos + out.length), temp.length)) + "&submit=Search";
		}
	}
}			
parent.window.open(temp);
}

function calculatetotal() {
packagecost = 0;
layoutcost = 0;
languagecost = 1.0;
logocost = 0;
imagecost = 0;
animadcost = 0;
flashcost = 0;
domaincost = 0;
databasecost = 0;
affiliatecost = 0;
IPcost = 0;
upgradecost = 0;
spacecost = 0;
bandwidthcost = 0;
totalcost = 0;

field=document.myform

if(field.registerdomain[1].checked){
	domaincost=68.00;
} else {
	domaincost=0;
}

if((field.designpages.value)>1) {
	packagecost=(100.00+((field.designpages.value)-1)*50.00);
} else {
	packagecost=100.00;
}
	
if(field.language[1].checked) {
	languagecost=120/100;
}
if((field.language[0].checked) || (field.language[2].checked)) {
	languagecost=1.0;
}

if(field.logo[2].selected) logocost=150.00;

if((field.numofproduct.value)>10) {
	imagecost=(field.numofproduct.value - 10)*1.00;
} else {
	imagecost=0;
	field.numofproduct.value=10;
}

if(field.templates[3].selected) layoutcost=200.00
if(field.animad[1].checked) animadcost=100.00;
if(field.flash[1].checked) flashcost=600.00;

if(field.upgrade[1].checked) {
	if(field.registerdomain[1].checked) {
		upgradecost=0;
	} else {
		upgradecost=50.00;
	}
}

totalcost=domaincost+IPcost+spacecost+bandwidthcost+(packagecost+layoutcost+
logocost+imagecost+animadcost+flashcost+databasecost+affiliatecost+upgradecost)*languagecost;
field.totalpayment.value=totalcost;

}

function PreviewPic(sel) {
document.pictures.src = "" + sel.options[sel.selectedIndex].value;
calculatetotal();
}

function ShowPic(sel) {
images = new Array();
images[1] = "templates/L0001/index.html";
images[2] = "templates/L0002/index.html";
images[3] = "templates/L0003/index.html";
images[4] = "templates/coming.htm";
window.open(images[sel.selectedIndex+1]);
}

function checkplan() {

field=document.myform
if(field.hostplan[0].checked) {
	field.domaintoregister.style.visibility="VISIBLE";
}

if(field.hostplan[1].checked) {
	field.domaintoregister.style.visibility="VISIBLE";
}

}

function caltotalcost() {
positioncost = 0;
registercost = 0;
totalcost = 0;

field=document.myform
ns=field.numofsubmitpage.value

if(!(field.positioning.checked) && !(field.registeradomain.checked)) {
	alert("You must choose a service to proceed.");
}

if(field.positioning.checked) {
	positioncost=150.00;
	field.numofsubmitpage.style.visibility="VISIBLE";
	field.page_to_submit.style.visibility="VISIBLE";
	if(ns<1) field.numofsubmitpage.value=1;
	ns=field.numofsubmitpage.value;
	positioncost=150.00*ns;
} else {
	field.numofsubmitpage.style.visibility="HIDDEN";
	field.page_to_submit.style.visibility="HIDDEN";
	positioncost=0;

}

if(field.registeradomain.checked) {
	registercost=68.00;
	field.domaintoberegister.style.visibility="VISIBLE";
	field.domaintoberegister.focus();
} else {
	field.domaintoberegister.style.visibility="HIDDEN";
	registercost=0.00;
}

totalcost=positioncost+registercost
field.totalpayment.value=totalcost
}

function opensecurepayment() {

field=document.myform
if(field.payment[0].checked) temp="http://auth.paysystems.com/sale.asp?pd_info=0A795DE637A622DCBCA4F72803ED1F9881031D1C9B8B5A8B15072156D3C07C0E";
if(field.payment[1].checked) temp="http://auth.paysystems.com/sale.asp?pd_info=0D9EACDC1C3EC1C16AC1DF09825EBF9FA18C4D677980A1182BB6EB1C5796801B";
if(field.payment[2].checked) temp="http://auth.paysystems.com/sale.asp?pd_info=4AA8E708655F915E8EA679ADCE92A4F3D1D603A0E81953944C6271882EC94806";
if(field.payment[3].checked) temp="http://auth.paysystems.com/sale.asp?pd_info=2E0771EB908638645361546F771D8891CCF44A15B66B7A1B4DABBAC8C18531EC0B9A927EC9AE97F5";
if(field.payment[4].checked) temp="http://auth.paysystems.com/sale.asp?pd_info=CFF6F38B1BADA2098C7070884D16FDFBCE70ACEE16AAD5A17C856D7F9D29643EDFF9C19739699065";
if(field.payment[5].checked) temp="http://auth.paysystems.com/sale.asp?pd_info=43C59629A44C4FB84FE73F596025C4B4C929B11D092E3C279E2E33F06063B83C";
if(field.payment[6].checked) temp="http://auth.paysystems.com/sale.asp?pd_info=40C2C72288357F076047137ABB279C9443C7244199681229D36FBD050C93B295";
if(field.payment[7].checked) temp="http://auth.paysystems.com/sale.asp?pd_info=E67A2A8D3B2177877CCAECD7A025B5BB8129CD9DCFBE49E4D70DB8AF58E06E1A";
if(field.payment[8].checked) temp="http://auth.paysystems.com/sale.asp?pd_info=A2EB1F3199D9B0AA8171629126171E665872E41F90E31D3904DE535517EB758A";
if(field.payment[9].checked) temp="http://auth.paysystems.com/sale.asp?pd_info=23F23E969E087E597A4FBF4272C18B92FB1593476CCFC168B30090AA24A76F8D";
if(field.payment[10].checked) temp="http://auth.paysystems.com/sale.asp?pd_info=0F1FF677B173C391A8A27C0E4E50EA248266C138000CAD0BF8909EA1D5D8598E";
if(field.payment[11].checked) temp="http://auth.paysystems.com/sale.asp?pd_info=3978830EF4D46669C82F045DE0009BA0C14F4CDB2500DA0D4FC4286FB2F16F5A";
if(field.payment[12].checked) temp="http://auth.paysystems.com/sale.asp?pd_info=26DF36DB1EF78E6CA85BEDE797B785905D6522658B952EEB336E5DEC7F9A9539";
location.href=temp;
}

