//easy.js -- do the client side work for surfprint easy
//

// written by and copyright Tom Cranstoun, working through DDT Technology LTD, All rights reserved Apr 2005
//
//	first released version
//


////////////////////////////////////////////////////////////////////////////////////////

function verApp(wanted)
{
	return(1)
}
///////////////////////////////////////////////////////////////////////////////////////


function winopenoffer(){ 
	window.open("offer.htm","offer","width=650,height=500,scrollbars=yes,resizable=yes") 
} 
function winopenpreview(){ 
	window.open("preview.htm","preview","width=265,height=180,scrollbars=no,resizable=no") 
} 
function winopendemo(){ 
	window.open("faq.htm","faq","width=650,height=500,scrollbars=yes,resizable=yes") 
} 
function winopentc(){ 
	window.open("tandc.htm","TermsAndConditions","width=650,height=500,scrollbars=yes,resizable=yes") 
} 
function winopenprices(){ 
	window.open("images/pricingmatrix.gif","prices","width=260,height=365,scrollbars=no,resizable=no") 
} 
function winopenhelp(){ 
	window.open("help.html","helpwin","width=650,height=500,scrollbars=yes,resizable=yes") 
} 

function setDunit() {
deleteCookie("dunit")
setCookie("dunit","Y")
}

function chooseposition(p) {

var Vout = ''
Vout = stringit(p)
window.location = 'positionselect.aspx?'+Vout

}

function choosecfs(p) {

var Vout = ''

Vout = stringit(p)
window.location = 'select.aspx?type=cfs&'+Vout

}


function choosesfs(p) {

var Vout = ''
Vout = stringit(p)
window.location = 'select.aspx?type=sfs&'+Vout

}


function choosenfs(p) {

var Vout = ''
Vout = stringit(p)
window.location = 'select.aspx?type=nfs&'+Vout

}


function chooselayout(p) {

var Vout = ''
Vout = stringit(p)
window.location = 'layoutselect.aspx?'+Vout

}

function chooseheadlinepalette(p) {

var Vout = ''
Vout = stringit(p)
window.location = 'headlinepaletteselect.aspx?'+Vout

}

function choosebodypalette(p) {

var Vout = ''
Vout = stringit(p)
window.location = 'bodypaletteselect.aspx?'+Vout

}


function chooseheadlinefont(p) {

var Vout = ''
Vout = stringit(p)
window.location = 'headlinefontselect.aspx?'+Vout

}

function choosebodyfont(p) {

var Vout = ''
Vout = stringit(p)
window.location = 'bodyfontselect.aspx?'+Vout

}

function choosegraphic(p) {

var Vout = ''
Vout = stringit(p)
window.location = 'graphicselect.aspx?'+Vout

}
function choosenotown(p) {

var Vout = ''
Vout = stringit(p)
window.location = 'reset.aspx'
}

function choosecolourbackground(p){
var Vout = ''
Vout = stringit('')
window.location = 'backgroundselect.aspx?'+p+'&'+Vout


}

function choosebackground(p) {

var Vout = ''
Vout = stringit(p)
window.location = 'backgroundselect.aspx?'+Vout

}


function designit(p) {

var Vout = ''
Vout = stringit(p)
window.location = 'http://www.surfprint.co.uk/product.aspx?type=pc-bc&refer=1'

}

function orderit(p) {

var Vout = ''
Vout = stringit(p)
//alert(Vout)
if (p =='Order' ) window.location =  "Order.aspx?"+Vout 
else window.location = "default.aspx?"+Vout

}

function stringit(p,second) {

var i
var j
var Vout = ''

	//Vout = second


j = myform.elements.length





for (i = 0;i<j;i++) {
if (Vout != '' ) { 
	Vout = Vout + "&" 
}
Vout = Vout + myform.elements[i].name + "=" + encodeURIComponent(encode(myform.elements[i].value) + "")
Vout = Vout
}

return Vout

}



function encode(ains) {
var aans
var c 
var i
var ins

ins = ains

aans = ""

for (i=0;i<ins.length;i++) {
	c = ins.charAt(i,1)
	switch (c) {
	
		case '?':
			aans=aans+'/#63#'
			break
		case '/':
			aans=aans+'//'
			break
		case "'":
			if (i==0) {
			aans=aans+ "/#145#"
			}
			else {
				if (ins.charAt(i-1,1)==' ') {
			    		aans=aans+"/#145#"
				} else {
					aans=aans+"/#146#"
			        }

			}

			break
		case '"':
			
			if (i==0) {
			aans=aans+"/#147#"
			}
			else {
				if (ins.charAt(i-1,1)==' ') {
			    		aans=aans+"/#147#"
				} else {
					aans=aans+"/#148#"
			        }

			}

			break
		case '|':
			aans = aans+"/#124#"
			break
		case ':':
			aans=aans+"/c"
			break
		case '#':
			aans=aans+"/h"
			break
		case '>':
			aans=aans+"/g"
			break
		case '£':
			aans=aans+"/l"
			break
		case '+':
			aans=aans+"/p"
			break
		case "%":
			aans =aans+ "%25"
			break
		case ")":
			aans =aans+ "/#41#"
			break
		case "]":
			aans =aans+ "/#93#"
			break
		case "$":
			aans =aans+ "/#36#"
			break
		default:
			if (ins.charAt(i,1) > 127) {
			aans=aans+"/#"+ins.charAt(i,1)+"#"
			}
			else {
				aans=aans + c
			}
		}
	}
if (aans==' ') {
	aans=' '
}
return(aans)
}
function setCookie( name, value, expires, path, domain, secure ) {
  var today = new Date();
  today.setTime( today.getTime() );
  if ( expires ) {
    expires = expires * 1000 * 60 * 60 * 24;
  }
  var expires_date = new Date( today.getTime() + (expires) );
  document.cookie = name+"="+escape( value ) +
    ( ( expires ) ? ";expires="+expires_date.toGMTString() : "" ) + //expires.toGMTString()
    ( ( path ) ? ";path=" + path : "" ) +
    ( ( domain ) ? ";domain=" + domain : "" ) +
    ( ( secure ) ? ";secure" : "" );
}

function deleteCookie( name, path, domain ) {
  if ( getCookie( name ) ) document.cookie = name + "=" +
    ( ( path ) ? ";path=" + path : "") +
    ( ( domain ) ? ";domain=" + domain : "" ) +
    ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function getCookie( name ) {
  var start = document.cookie.indexOf( name + "=" );
  var len = start + name.length + 1;
  if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
    return null;
  }
  if ( start == -1 ) return null;
  var end = document.cookie.indexOf( ";", len );
  if ( end == -1 ) end = document.cookie.length;
  return unescape( document.cookie.substring( len, end ) );
}



