// AJAX VARIABLES AND STUFF
var ajax = false;
ajax = createAjax();
var attributes = 3;
var deletedPictureID = 0;
var deletedItemFromShoppingCart = 0;
var deletedItemFromOrders = 0;
var completedItemFromOrder = 0;
var draggableDiv = null;
var initialPosition;


//AJAX START UP
function createAjax() {
	var ro;
	if(window.XMLHttpRequest){
		ro = new XMLHttpRequest();
	}else if (window.ActiveXObject) {
		//alert("ie");
		try{
			ro = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				ro = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(e){
				ro = false
			}
		}
	}
	return ro;
}

// CALL IN PROGRESS FUNCTION
function callInProgress() {
	if (ajax.readyState == 4 || ajax.readyState == 0) {
		return false;
	} else {
		return true;
	}
}

// show the add attribute box
function addAttribute() {
	attributes ++;
	var d = document.getElementById("_attributes");
	var tb = document.createElement("tbody");
	var newTR = document.createElement("tr");
	var newTD = document.createElement("td");
	var t = '<table id="attribute'+attributes+'" border="0" width="100%"><tr><td>Name:</td><td><input class="generalInput" type="text" name="attributes['+attributes+']"></td></tr><tr><td>Summary text:</td><td><input class="generalInput" type="text" name="summary['+attributes+']"></td></tr><tr><td>Order:</td><td><input class="generalInput" type="text" name="order['+attributes+']" value="0"></td></tr><tr><td>Values:<td><td><img style="cursor:pointer;" onclick="addValue('+attributes+')" src="../images/general/add_attribute.jpg"></td></tr></table>';
	newTD.innerHTML = t;
	newTR.appendChild(newTD);
	tb.appendChild(newTR);
	d.appendChild(tb);
}


// add another input set for a new value
function addValue(id) {
	var d     = document.getElementById("attribute"+id);
	var tb    = document.createElement("tbody");


	// Add Row 1
	var newTR = document.createElement("tr");

	var t     = 'Description:';
	var newTD = document.createElement("td");
	newTD.innerHTML = t;
	newTR.appendChild(newTD);

	var t     = '<input type="text" name="values'+id+'[]" class="generalInput">';
	var newTD = document.createElement("td");
	newTD.innerHTML = t;
	newTR.appendChild(newTD);
	tb.appendChild(newTR);

	// Add Row 2
	var newTR = document.createElement("tr");

	var t     = 'Price:';
	var newTD = document.createElement("td");
	newTD.innerHTML = t;
	newTR.appendChild(newTD);

	var t     = '<input  type="text" name="prices'+id+'[]" class="price">';
	var newTD = document.createElement("td");
	newTD.innerHTML = t;
	newTR.appendChild(newTD);
	tb.appendChild(newTR);

	// Add Row 3
	var newTR = document.createElement("tr");

	var t     = 'Summary text:';
	var newTD = document.createElement("td");
	newTD.innerHTML = t;
	newTR.appendChild(newTD);

	var t     = '<input type="text" name="summary'+id+'[]"  class="generalInput">';
	var newTD = document.createElement("td");
	newTD.innerHTML = t;
	newTR.appendChild(newTD);
	tb.appendChild(newTR);

	// Add Row 4
	var newTR = document.createElement("tr");

	var t     = 'Order:';
	var newTD = document.createElement("td");
	newTD.innerHTML = t;
	newTR.appendChild(newTD);

	var t     = '<input type="text" name="order'+id+'[]"  class="generalInput">';
	var newTD = document.createElement("td");
	newTD.innerHTML = t;
	newTR.appendChild(newTD);
	tb.appendChild(newTR);

	// Add Row 4
	var newTR = document.createElement("tr");

	var newTD = document.createElement("td");
	newTR.appendChild(newTD);
	newTD.setAttribute('colspan','2');
	newTD.setAttribute('bgcolor','#EDEDED');
	newTD.setAttribute('height','1');

	newTR.appendChild(newTD);
	tb.appendChild(newTR);

	d.appendChild(tb);

}

function addPicture() {
	var d = document.getElementById("_pictures");
	var newTR = document.createElement("tr");
	var newTD = document.createElement("td");

	var t = '<fieldset><legend>Upload picture</legend><input type="hidden" name="MAX_FILE_SIZE" value="1002000" /><input name="photo[]" type="file" /><br /><select name="onlyExamples[]"><option value="1">Show only in details</option><option value="0" selected>Show everywhere</option></select></fieldset>';
	newTD.innerHTML = t;
	newTR.appendChild(newTD);
	d.appendChild(newTR);
}

function deletePicture(id,pic_id) {
	//alert(id+'-'+pic_id);
	if (!callInProgress()) {
		// ok can send delete order
		var ok = confirm("Are you sure you want to delete this picture?");
		if (ok) {
		deletedPictureID = ""+id+pic_id;
		ajax.open("GET","../ajax/deletePicture.php?p_id="+id+"&pic_id="+pic_id);
		ajax.onreadystatechange = processDeletePicture;
		ajax.send(null);
		}
	} else {
		setTimeout("deletePicture("+id+","+pic_id+")",100);
	}
}

function processDeletePicture() {
	if (ajax.readyState == 4) {
		if (ajax.responseText == 1) {
			// all ok
			//alert(deletedPictureID);
			document.getElementById(deletedPictureID).innerHTML = "";
		} else {
			alert("There has been an internal problem. Please retry later.");
		}
	}
}

function switchPicture(pic,url) {
	document.getElementById(pic).src=url;
}

function showShoppingCartDetailsBox(id,sID) {
	resetShoppingCartDetailsBox();
	var x = document.getElementById('shoppingCartDetailsBox');
	var width,height;
	if (self.innerHeight) // all except Explorer
	{
		width = self.innerWidth;
		height = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	// Explorer 6 Strict Mode
	{
		width = document.documentElement.clientWidth;
		height = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		width = document.body.clientWidth;
		height = document.body.clientHeight;
	}
	var xpos = (width - 500 ) / 2;
	var ypos = (height - 500) / 2;
	x.style.display = "block";
	x.style.left = xpos;
	x.style.top  = ypos;
	loadDetails(id,sID);
}

function loadDetails(id,sID) {
	if (!callInProgress()) {
		ajax.open("GET","ajax/itemDetails.php?id="+id+"&sID="+sID);
		ajax.onreadystatechange = processDetails;
		ajax.send(null);
	} else {
		setTimeout("loadDetails("+id+")",100);
	}
}

function processDetails() {
	if (ajax.readyState == 4) {
		var x = document.getElementById('shoppingCartDetailsBoxContinut');
		if (ajax.responseText == 1) {
			x.innerHTML = "There was an internal error. Please retry later.";
		} else {
			x.innerHTML = ajax.responseText;
		}
	}
}

function hideShoppingCartDetailsBox() {
	var x = document.getElementById('shoppingCartDetailsBox');
	x.style.display = "none";
}

function resetShoppingCartDetailsBox() {
	var x = document.getElementById('shoppingCartDetailsBoxContinut');
	x.innerHTML = '<img src="images/general/loading2.gif"><br />Loading details...';
}

// Gift Certificate details box functions
function showShoppingCartGiftDetailsBox(id) {
	resetShoppingCartGiftDetailsBox();
	var x = document.getElementById('shoppingCartGiftDetailsBox');
	var width,height;
	if (self.innerHeight) // all except Explorer
	{
		width = self.innerWidth;
		height = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	// Explorer 6 Strict Mode
	{
		width = document.documentElement.clientWidth;
		height = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		width = document.body.clientWidth;
		height = document.body.clientHeight;
	}
	var xpos = (width - 500 ) / 2;
	var ypos = (height - 500) / 2;
	x.style.display = "block";
	x.style.left = xpos;
	x.style.top  = ypos;
	loadGiftDetails(id);
}

function loadGiftDetails(id,sID) {
	if (!callInProgress()) {
		ajax.open("GET","ajax/giftDetails.php?id="+id);
		ajax.onreadystatechange = processGiftDetails;
		ajax.send(null);
	} else {
		setTimeout("loadDetails("+id+")",100);
	}
}

function processGiftDetails() {
	if (ajax.readyState == 4) {
		var x = document.getElementById('shoppingCartGiftDetailsBoxContinut');
		if (ajax.responseText == 1) {
			x.innerHTML = "There was an internal error. Please retry later.";
		} else {
			x.innerHTML = ajax.responseText;
		}
	}
}

function hideShoppingCartGiftDetailsBox() {
	var x = document.getElementById('shoppingCartGiftDetailsBox');
	x.style.display = "none";
}

function resetShoppingCartGiftDetailsBox() {
	var x = document.getElementById('shoppingCartGiftDetailsBoxContinut');
	x.innerHTML = '<img src="images/general/loading2.gif"><br />Loading details...';
}

//------------------------------------------------------------------------------------------
function deleteFromShoppingCart(id) {
	if (!callInProgress()) {
		var ok = confirm("Are you sure you want to delete the item?");
		if (ok) {
		deletedItemFromShoppingCart = id;
		ajax.open("GET","ajax/deleteItemFromCart.php?id="+id);
		ajax.onreadystatechange = processDeleteFromCart;
		ajax.send(null);
		}
	} else {
		setTimeout("deleteFromShoppingCart("+id+")",100);
	}
}


function deleteSubItemFromShoppingCart(order,id) {
	if (!callInProgress()) {
		var ok = confirm("Are you sure you want to delete the item?");
		if (ok) {
		deletedSubItemFromShoppingCart = id;
		ajax.open("GET","ajax/deleteSubItemFromCart.php?order"+order +"id="+id);
		ajax.onreadystatechange = processDeleteFromCart;
		ajax.send(null);
		}
	} else {
		setTimeout("deleteSubItemFromShoppingCart("+order+","+id+")",100);
	}
}

function deleteFromShoppingCartGiftCard(id) {
	if (!callInProgress()) {
		var ok = confirm("Are you sure you want to delete the item?");
		if (ok) {
		deletedItemFromShoppingCart = id;
		ajax.open("GET","ajax/deleteGiftFromCart.php?id="+id);
		ajax.onreadystatechange = processDeleteGiftFromCart;
		ajax.send(null);
		}
	} else {
		setTimeout("deleteFromShoppingCart("+id+")",100);
	}
}

function processDeleteFromCart() {
	if (ajax.readyState == 4) {
		if (ajax.responseText == 1) {
			// ok deleted
			// get the price of the item
			var price = parseFloat(document.getElementById("_priceItem"+deletedItemFromShoppingCart+"_").innerHTML);
			var x = document.getElementById('shoppingCartItem'+deletedItemFromShoppingCart);
			x.parentNode.removeChild(x);
			var total = parseFloat(document.getElementById("_total_").innerHTML);
			total -= price;
			document.getElementById("_total_").innerHTML = total;

		} else {
			//alert(ajax.responseText);
		}
		location.reload(true);
	}
}

function processDeleteSubItemFromCart() {
	if (ajax.readyState == 4) {
		if (ajax.responseText == 1) {
			// ok deleted
			// get the price of the item
			var price = parseFloat(document.getElementById("_priceSubItem"+deletedSubItemFromShoppingCart+"_").innerHTML);
			var x = document.getElementById('shoppingCartSubItem'+deletedItemFromShoppingCart);
			x.parentNode.removeChild(x);
			var total = parseFloat(document.getElementById("_total_").innerHTML);
			total -= price;
			document.getElementById("_total_").innerHTML = total;

		} else {
			//alert(ajax.responseText);
		}
		location.reload(true);
	}
}

function processDeleteGiftFromCart() {
	if (ajax.readyState == 4) {
		if (ajax.responseText == 1) {
			// ok deleted
			var x = document.getElementById('shoppingCartGiftCard'+deletedItemFromShoppingCart);
			x.parentNode.removeChild(x);
			location.reload(true);
		} else {
			alert(ajax.responseText);
		}
	}
}

function deleteOrder(id) {
	//alert(tr);
	//alert(id);
	if (!callInProgress()) {
		var ok = confirm("Are you sure you want to delete this order?");
		if (ok == true) {
			deletedItemFromOrders = id;
			ajax.open("GET","../ajax/deleteItemFromOrders.php?id="+id);
			ajax.onreadystatechange = processDeleteOrder;
			ajax.send(null);
		}
	} else {
		setTimeout("deleteOrder("+id+")",100);
	}
}

function deleteGiftCard(id) {
	//alert(tr);
	//alert(id);
	if (!callInProgress()) {
		var ok = confirm("Are you sure you want to delete this Gift Certificate?");
		if (ok == true) {
			deletedItemFromGiftCards = id;
			ajax.open("GET","../ajax/deleteItemFromGiftCards.php?id="+id);
			ajax.onreadystatechange = processDeleteGiftCard;
			ajax.send(null);
		}
	} else {
		setTimeout("deleteGiftCard("+id+")",100);
	}
}
function processDeleteGiftCard() {
	if (ajax.readyState == 4) {

		if (ajax.responseText == 1) {
			var x = document.getElementById("order_"+deletedItemFromGiftCards);
			x.parentNode.removeChild(x);
		} else {
			alert(ajax.responseText);
		}
	}
}

function processDeleteOrder() {
	if (ajax.readyState == 4) {

		if (ajax.responseText == 1) {
			// ok deleted
			var x = document.getElementById("order_"+deletedItemFromOrders);
			x.parentNode.removeChild(x);
		} else {
			alert(ajax.responseText);
		}
	}
}


function rejectOrder(id) {
	if (!callInProgress()) {
		var ok = confirm("Are you sure you want to reject this order?");
		if (ok == true) {
			rejectedItemFromOrder = id;
			ajax.open("GET","../ajax/rejectOrder.php?id="+id);
			ajax.onreadystatechange = processRejectOrder;
			ajax.send(null);
		}
	} else {
		setTimeout("rejectOrder("+id+")",100);
	}
}


function holdOrder(id) {
    if (!callInProgress()) {
        var ok = confirm("Are you sure you want to put this order on hold?");
        if (ok == true) {
            rejectedItemFromOrder = id;
            ajax.open("GET","../ajax/holdOrder.php?id="+id);
            ajax.onreadystatechange = processRejectOrder;
            ajax.send(null);
        }
    } else {
        setTimeout("holdOrder("+id+")",100);
    }
}

function settleOrder(id) {
    if (!callInProgress()) {
        var ok = confirm("Are you sure you want to mark this order as settled?");
        if (ok == true) {
            rejectedItemFromOrder = id;
            ajax.open("GET","../ajax/settleOrder.php?id="+id);
            ajax.onreadystatechange = processRejectOrder;
            ajax.send(null);
        }
    } else {
        setTimeout("settleOrder("+id+")",100);
    }
}

function sendToWeaverOrder(id) {
    if (!callInProgress()) {
        var ok = confirm("Are you sure you want to send this order to Weaver?");
        if (ok == true) {
            rejectedItemFromOrder = id;
            ajax.open("GET","../ajax/sendToWeaverOrder.php?id="+id);
            ajax.onreadystatechange = processRejectOrder;
            ajax.send(null);
        }
    } else {
        setTimeout("settleOrder("+id+")",100);
    }
}



function processRejectOrder() {
	if (ajax.readyState == 4) {
		if (ajax.responseText == 1) {
			var x = document.getElementById("order_"+rejectedItemFromOrder);
			x.parentNode.removeChild(x);
		} else {
			alert(ajax.responseText);
		}
	}
}

function completeOrder(id) {
	if (!callInProgress()) {
		completedItemFromOrder = id;
		ajax.open("GET","../ajax/completeOrder.php?id="+id);
		ajax.onreadystatechange = processCompleteOrder;
		ajax.send(null);
	} else {
		setTimeout("completeOrder("+id+")",100);
	}
}
function processCompleteOrder() {
	if (ajax.readyState == 4) {
		if (ajax.responseText == 1) {
			var x = document.getElementById("order_"+completedItemFromOrder);
			x.parentNode.removeChild(x);
		} else {
			alert(ajax.responseText);
		}
	}
}



function sendToFtp(id) {
	if (!callInProgress()) {
		alert('me');
		completedItemFromOrder = id;
		ajax.open("GET","../ajax/sendToFtp.php?id="+id);
		// ajax.onreadystatechange = processCompleteOrder;
		ajax.send(null);
		alert('OK');
	} else {
		setTimeout("sendToFtp("+id+")",100);
	}
}



function pendingOrder(id) {
	if (!callInProgress()) {
		pendingItemFromOrder = id;
		ajax.open("GET","../ajax/pendingOrder.php?id="+id);
		ajax.onreadystatechange = processPendingOrder;
		ajax.send(null);
	} else {
		setTimeout("pendingOrder("+id+")",100);
	}
}
function processPendingOrder() {
	if (ajax.readyState == 4) {
		if (ajax.responseText == 1) {
			var x = document.getElementById("order_"+pendingItemFromOrder);
			x.parentNode.removeChild(x);
		} else {
			alert(ajax.responseText);
		}
	}
}

function showOrderDetails(id) {
	if (!callInProgress()) {
		resetOrderDetailsBox();
		var x = document.getElementById('orderDetailsBox');
		var width,height;
		if (self.innerHeight) // all except Explorer
		{
			width = self.innerWidth;
			height = self.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
		{
			width = document.documentElement.clientWidth;
			height = document.documentElement.clientHeight;
		}
		else if (document.body) // other Explorers
		{
			width = document.body.clientWidth;
			height = document.body.clientHeight;
		}
		
		var xpos = 20;
	  var ypos = 20;
		x.style.left = xpos;
		x.style.top = ypos;
		x.style.display = "block";
		var y = document.getElementById('ordersItemBox');
		y.innerHTML = "";
		ajax.open("GET","../ajax/orderDetails.php?id="+id);
		ajax.onreadystatechange = processOrderDetails;
		ajax.send(null);
	} else {
		setTimeout("showOrderDetails("+id+")",100);
	}
}


function showOrderDetails2(id) {
	if (!callInProgress()) {
		resetOrderDetailsBox();
		var x = document.getElementById('orderDetailsBox');
		var width,height;
		if (self.innerHeight) // all except Explorer
		{
			width = self.innerWidth;
			height = self.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
		{
			width = document.documentElement.clientWidth;
			height = document.documentElement.clientHeight;
		}
		else if (document.body) // other Explorers
		{
			width = document.body.clientWidth;
			height = document.body.clientHeight;
		}
		x.style.left = 0;
		x.style.top = 0;
		x.style.display = "block";
		var y = document.getElementById('ordersItemBox');
		y.innerHTML = "";
		ajax.open("GET","../ajax/orderDetails2.php?id="+id);
		ajax.onreadystatechange = processOrderDetails;
		ajax.send(null);
	} else {
		setTimeout("showOrderDetails("+id+")",100);
	}
}








function show2OrderDetails(id) {
	if (!callInProgress()) {
		resetOrderDetailsBox();
		var x = document.getElementById('orderDetailsBox');
		var width,height;
		if (self.innerHeight) // all except Explorer
		{
			width = self.innerWidth;
			height = self.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
		{
			width = document.documentElement.clientWidth;
			height = document.documentElement.clientHeight;
		}
		else if (document.body) // other Explorers
		{
			width = document.body.clientWidth;
			height = document.body.clientHeight;
		}
		x.style.left = 0;
		x.style.top = 0;
		x.style.display = "block";
		var y = document.getElementById('ordersItemBox');
		y.innerHTML = "";
		ajax.open("GET","../ajax/orderDetails.php?id="+id);
		ajax.onreadystatechange = processOrderDetails;
		ajax.send(null);
	} else {
		setTimeout("showOrderDetails("+id+")",100);
	}
}
function show2OrderDetails2(id) {
	if (!callInProgress()) {
		resetOrderDetailsBox();
		var x = document.getElementById('orderDetailsBox');
		var width,height;
		if (self.innerHeight) // all except Explorer
		{
			width = self.innerWidth;
			height = self.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
		{
			width = document.documentElement.clientWidth;
			height = document.documentElement.clientHeight;
		}
		else if (document.body) // other Explorers
		{
			width = document.body.clientWidth;
			height = document.body.clientHeight;
		}
		x.style.left = 0;
		x.style.top = 0;
		x.style.display = "block";
		var y = document.getElementById('ordersItemBox');
		y.innerHTML = "";
		ajax.open("GET","../ajax/orderDetails2.php?id="+id);
		ajax.onreadystatechange = processOrderDetails;
		ajax.send(null);
	} else {
		setTimeout("showOrderDetails("+id+")",100);
	}
}








function processOrderDetails() {
	if (ajax.readyState == 4) {
		var x = document.getElementById("orderDetailsBoxContinut");
		x.innerHTML = ajax.responseText;
	}
}
function resetOrderDetailsBox() {
	var x = document.getElementById("orderDetailsBoxContinut");
	x.innerHTML = '<img src="../images/general/loading2.gif"><br />Loading details...';
}

function hideOrderDetailsBox() {
	document.getElementById("orderDetailsBox").style.display = "none";
	document.getElementById("_selectType").style.display='inline';
}

function showOrderItem(order_id,id,grupa) {
	resetOrderItemBox();
	if (!callInProgress()) {
		ajax.open("GET","../ajax/itemDetailsAdmin.php?order_id="+order_id+"&id="+id+"&grupa="+grupa);
		ajax.onreadystatechange = processOrderItem;
		ajax.send(null);
	} else {
		setTimeout("showOrderItem("+order_id+","+id+","+grupa+")",100);
	}
}
function processOrderItem() {
	if (ajax.readyState == 4) {
		var x = document.getElementById("ordersItemBox");
		x.innerHTML = ajax.responseText;
	}
}
function resetOrderItemBox() {
	var x = document.getElementById('ordersItemBox');
	x.innerHTML = '<center><img src="../images/general/loading2.gif"><br />Loading ...</center>';
}
function showItemExamples(id) {
	if (!callInProgress()) {
		hideAllSelects();
		resetItemExamplesBox();
		var x = document.getElementById('itemExamplesBox');
		var width,height;
		if (self.innerHeight) // all except Explorer
		{
			width = self.innerWidth;
			height = self.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
		{
			width = document.documentElement.clientWidth;
			height = document.documentElement.clientHeight;
		}
		else if (document.body) // other Explorers
		{
			width = document.body.clientWidth;
			height = document.body.clientHeight;
		}
		x.style.left = 0;
		x.style.top = 0;
		x.style.display = "block";
		ajax.open("GET","ajax/itemExamples.php?id="+id);
		ajax.onreadystatechange = processItemExamples;
		ajax.send(null);
	} else {
		setTimeout("showItemExamples("+id+")",100);
	}
}
function processItemExamples() {
	if (ajax.readyState == 4) {
		var x = document.getElementById('itemExamplesBoxContinut');
		x.innerHTML = ajax.responseText;
		//alert(ajax.responseText);
	}
}
function resetItemExamplesBox() {
	var x = document.getElementById('itemExamplesBoxContinut');
	x.innerHTML = '<center><img src="images/general/loading2.gif"><br />Loading ...</center>';
}
function hideItemExamplesBox() {
	var x = document.getElementById('itemExamplesBox');
	x.style.display = "none";
	showAllSelects();
}
// effects functions
function showEffectsExamples(id) {
	if (!callInProgress()) {
		hideAllSelects();
		resetItemExamplesBox();
		var x = document.getElementById('itemExamplesBox');
		var width,height;
		if (self.innerHeight) // all except Explorer
		{
			width = self.innerWidth;
			height = self.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
		{
			width = document.documentElement.clientWidth;
			height = document.documentElement.clientHeight;
		}
		else if (document.body) // other Explorers
		{
			width = document.body.clientWidth;
			height = document.body.clientHeight;
		}
		x.style.left = 0;
		x.style.top = 0;
		x.style.display = "block";
		ajax.open("GET","effects_examples.php?cat="+id);
		ajax.onreadystatechange = processEffectExamples;
		ajax.send(null);
	} else {
		setTimeout("showEffectExamples("+id+")",100);
	}
}
function processEffectExamples() {
	if (ajax.readyState == 4) {
		var x = document.getElementById('itemExamplesBoxContinut');
		x.innerHTML = ajax.responseText;
		//alert(ajax.responseText);
	}
}
function resetEffectsExamplesBox() {
	var x = document.getElementById('itemExamplesBoxContinut');
	x.innerHTML = '<center><img src="images/general/loading2.gif"><br />Loading ...</center>';
}
function hideEffectsExamplesBox() {
	var x = document.getElementById('itemExamplesBox');
	x.style.display = "none";
	showAllSelects();
}
// end of effects functions

function hideAllSelects(){
	var x = document.getElementsByTagName("select");
	for (i=0;i<x.length;i++) {
		x[i].style.display = "none";
	}
}
function showAllSelects(){
	var x = document.getElementsByTagName("select");
	for (i=0;i<x.length;i++) {
		x[i].style.display = "inline";
	}
}

function showAffDetails(id) {
	if (!callInProgress()) {
		resetAffDetails();
		var x = document.getElementById("affDetails");
		x.style.display = "block";
		var width,height;
		if (self.innerHeight) // all except Explorer
		{
			width = self.innerWidth;
			height = self.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
		{
			width = document.documentElement.clientWidth;
			height = document.documentElement.clientHeight;
		}
		else if (document.body) // other Explorers
		{
			width = document.body.clientWidth;
			height = document.body.clientHeight;
		}
		var ypos = 0;
		//x.style.display = "block";
		x.style.left = ypos;
		x.style.top = ypos;


		ajax.open("GET","../ajax/affDetails.php?id="+id);
		ajax.onreadystatechange = processAffDetails;
		ajax.send(null);
	} else {
		setTimeout("showAffDetails("+id+")",100);
	}
}
function resetAffDetails() {
	var x = document.getElementById('affDetailsContinut');
	x.innerHTML = '<center><img src="../images/general/loading2.gif"><br />Loading ...</center>';
}
function hideAffDetails() {
	var x = document.getElementById("affDetails");
	x.style.display = "none";
}
function processAffDetails() {
	if (ajax.readyState == 4) {
		var x = document.getElementById('affDetailsContinut');
		x.innerHTML = ajax.responseText;
	}
}

function deleteAffiliate(id) {
	if (!callInProgress()) {
		var ok = confirm("Are you sure you want to delete this affiliate account?");
		if (ok == true) {
			ajax.open("GET","../ajax/deleteAffiliate.php?id="+id);
			ajax.onreadystatechange = processAffDelete;
			ajax.send(null);
		}
	} else {
		setTimeout("deleteAffiliate("+id+")",100);
	}
}
function processAffDelete() {
	if (ajax.readyState == 4) {
		if (ajax.responseText != 0) {
			var x = document.getElementById("_tr_"+ajax.responseText);
			x.parentNode.removeChild(x);
			alert("The affiliate account was deleted.");
		} else {
			alert("The account could not be deleted. please retry later.");
		}
	}
}

function printComplete(id) {
	if (!callInProgress()) {
		pendingItemFromOrder = id;
		ajax.open("GET","../ajax/printComplete.php?id="+id);
		ajax.onreadystatechange = printCompleteProcess;
		ajax.send(null);
	} else {
		setTimeout("printComplete("+id+")",100);
	}
}
function printCompleteProcess() {
	if (ajax.readyState == 4) {
		if (ajax.responseText != 0 && ajax.responseText.length < 11) {
			var x = document.getElementById("order_"+ajax.responseText);
			x.parentNode.removeChild(x);
		} else {
			alert(ajax.responseText);
		}
	}
}

function shipmentComplete(id) {
	if (!callInProgress()) {
		pendingItemFromOrder = id;
		ajax.open("GET","../ajax/shipmentComplete.php?id="+id);
		ajax.onreadystatechange =shipmentCompleteProcess;
		ajax.send(null);
	} else {
		setTimeout("shipmentComplete("+id+")",100);
	}
}
function shipmentCompleteProcess() {
	if (ajax.readyState == 4) {
		if (ajax.responseText != 0 && ajax.responseText.length < 11) {
			var x = document.getElementById("order_"+ajax.responseText);
			x.parentNode.removeChild(x);
		} else {
			alert(ajax.responseText);
		}
	}
}
function showPhotoTips() {
	var x = document.getElementById("_photoTips_");
	x.style.display = "block";
	x.style.left = "0px";
	x.style.top = "0px";
	hideSelects();
}
function hidePhotoTips() {
	var x = document.getElementById("_photoTips_");
	x.style.display = "none";
	showSelects();
}

function showHelp() {
	var x = document.getElementById("_help_");
	x.style.display = "block";
	x.style.left = "0px";
	// x.style.left = "400px";
	hideSelects();
}
function hideHelp() {
	var x = document.getElementById("_help_");
	x.style.display = "none";
	showSelects();
}
function changeImageType(id) {
//alert(id);
	var x = document.getElementById("_imageType1_");
	var y = document.getElementById("_imageType2_");
	var z = document.getElementById("_imageType3_");
	if (id == 1 ) {
		x.style.display = "block";
		y.style.display = "none";
		z.style.display = "none";
		hideSubmitImage();
	} else if (id == 2) {
		x.style.display = "none";
		y.style.display = "block";
		z.style.display = "none";
		showSubmitImage();
	} else {
		x.style.display = "none";
		y.style.display = "none";
		z.style.display = "block";
		hideSubmitImage();
	}
}

function changeDeliveryType(id) {
//alert(id);
	var x = document.getElementById("_deliveryType1_");
	var y = document.getElementById("_deliveryType2_");
	if (id == 1 ) {
		x.style.display = "block";
		y.style.display = "none";
		hideSubmitImage();
	} else if (id == 2) {
		x.style.display = "none";
		y.style.display = "block";
	}
}


function hideSelects() {
	var x = document.getElementsByTagName('select');
	var i;
	var max;
	for (i=0,max=x.length;i<max;i++) {
		x[i].style.display = 'none';
	}
}

function showSelects() {
	var i;
	var max;
	var x = document.getElementsByTagName('select');
	for (i=0,max=x.length;i<max;i++) {
		x[i].style.display = 'inline';
	}
}

function confirmInformation() {
	var x = confirm("Are you sure this is your corect information?");
	if (x) {
		return true;
	} else {
		return false;
	}
}

function showPrintVersion(id) {
	var s = "printFriendly.php?orderID="+id;
	var pv = window.open(s,"Printer_Friendly_Version","menubar=0,scrollbars=1,status=0,width=600, height=500;");
}

function findPosX(a)
{
	var obj=document.getElementById(a);
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(a)
{
	var obj=document.getElementById(a);
	var curtop = 0;
	var printstring = '';
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			printstring += ' element ' + obj.tagName + ' has ' + obj.offsetTop;
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	window.status = printstring;
	return curtop;
}


function addMouseDrag(d) {
	draggableDiv = document.getElementById(d);
	document.onmousemove = dragDiv;
	var IE = document.all?true:false;
	if (IE) { // grab the x-y pos.s if browser is IE
	    tempX = event.clientX + document.body.scrollLeft
	    tempY = event.clientY + document.body.scrollTop
  	} else {  // grab the x-y pos.s if browser is NS
	    tempX = ev.pageX
	    tempY = ev.pageY
  	}
	// catch possible negative values in NS4
	if (tempX < 0){tempX = 0}
	if (tempY < 0){tempY = 0}
	initialPosition.mouseX = tempX;
	initialPosition.mouseY = tempY;
	initialPosition.divX = findPosX(d);
	initialPosition.divY = findPosY(d);
}
function removeMouseDrag(d) {
	draggableDiv = document.getElementById(d);
	draggableDiv.onmousemove = function(){};
}

function dragDiv(ev) {
	//alert(ev.screenX);
	//alert(ev.screenY);

	var IE = document.all?true:false;
	if (IE) { // grab the x-y pos.s if browser is IE
	    tempX = event.clientX + document.body.scrollLeft
	    tempY = event.clientY + document.body.scrollTop
  	} else {  // grab the x-y pos.s if browser is NS
	    tempX = ev.pageX
	    tempY = ev.pageY
  	}
	// catch possible negative values in NS4
	if (tempX < 0){tempX = 0}
	if (tempY < 0){tempY = 0}
	window.status=""+tempX+"-"+tempY;
	draggableDiv.style.left = initialPosition.divX + (tempX - initialPosition.mouseX);
	draggableDiv.style.top = initialPosition.divY + (tempY - initialPosition.mouseY);
}

document.onmousemove = mouseMove;
document.onmouseup   = mouseUp;

var dragObject  = null;
var mouseOffset = null;

function getMouseOffset(target, ev){
	ev = ev || window.event;

	var docPos    = getPosition(target);
	var mousePos  = mouseCoords(ev);
	return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y};
}

function getPosition(e){
	var left = 0;
	var top  = 0;

	while (e.offsetParent){
		left += e.offsetLeft;
		top  += e.offsetTop;
		e     = e.offsetParent;
	}

	left += e.offsetLeft;
	top  += e.offsetTop;

	return {x:left, y:top};
}

function mouseMove(ev){
	ev           = ev || window.event;
	var mousePos = mouseCoords(ev);

	if(dragObject){
		dragObject.style.position = 'absolute';
		dragObject.style.top      = mousePos.y - mouseOffset.y;
		dragObject.style.left     = mousePos.x - mouseOffset.x;

		return false;
	}
}
function mouseCoords(ev){
	if(ev.pageX || ev.pageY){
		return {x:ev.pageX, y:ev.pageY};
	}
	return {
		x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
		y:ev.clientY + document.body.scrollTop  - document.body.clientTop
	};
}
function mouseUp(){
	dragObject = null;
}

function makeDraggable(item){
	if(!item) return;
	item.onmousedown = function(ev){
		dragObject  = this;
		mouseOffset = getMouseOffset(this, ev);
		return false;
	}
}

function hideSubmitImage() {
	document.getElementById("_SubmitUploadPic_").style.display = "none";
}

function showSubmitImage() {
	document.getElementById("_SubmitUploadPic_").style.display = "block";
}

function loadGiftCardDetails(id) {
	if (!callInProgress()) {
		ajax.open("GET","../ajax/giftCardDetails.php?id="+id);
		ajax.onreadystatechange = getGiftCardDetails;
		ajax.send(null);
	} else {
		setTimeout("loadGiftCardDetails("+id+")",100);
	}
}

function getGiftCardDetails() {
	if (ajax.readyState == 4) {
		var x = document.getElementById("_GiftCardDetails_");
		x.innerHTML = ajax.responseText;
	}
}

function toggleSpecialInstructions() {
	var x = document.getElementById("specialInstructions");
	if (x.style.display == "block") {
		x.style.display = "none";
	} else {
		x.style.display = "block";
	}
}

function showT(q,order_no){
if (order_no < 687){ 
  document.getElementById('th_lnk').setAttribute('href','show_image.php?filename=../uploaded_images/'+q+'.jpg')
  document.getElementById('th_img').setAttribute('src','show_image.php?filename=../uploaded_images/'+q+'.jpg&width=200') 
} else {
  document.getElementById('th_lnk').setAttribute('href','show_image.php?filename=orders/'+order_no+'/images/'+q+'.jpg')
  document.getElementById('th_img').setAttribute('src' ,'show_image.php?filename=orders/'+order_no+'/images/'+q+'.jpg&width=200')
}
} 

/***********************************************
* Textarea Maxlength script- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}

function showGiftDetails(id) {
	if (!callInProgress()) {
		resetOrderDetailsBox();
		var x = document.getElementById('orderDetailsBox');
		var width,height;
		if (self.innerHeight) // all except Explorer
		{
			width = self.innerWidth;
			height = self.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
		{
			width = document.documentElement.clientWidth;
			height = document.documentElement.clientHeight;
		}
		else if (document.body) // other Explorers
		{
			width = document.body.clientWidth;
			height = document.body.clientHeight;
		}


		var xpos = (width  - 400 ) / 2;
		var ypos = (height - 400 ) / 2;
		x.style.display = "block";
		x.style.left = xpos;
		x.style.top  = ypos;


		var y = document.getElementById('ordersItemBox');
		y.innerHTML = "";
		ajax.open("GET","../ajax/giftCardDetails.php?id="+id);
		ajax.onreadystatechange = processOrderDetails;
		ajax.send(null);
	} else {
		setTimeout("showGiftDetails("+id+")",100);
	}
}
function goto(form) { 
        var index=form._selectType.selectedIndex;
        if (form._selectType.options[index].value != "0") {
                location=form._selectType.options[index].value;}
}



/***********************************************
* DHTML Ticker script- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

function domticker(content, divId, divClass, delay, fadeornot){
this.content=content
this.tickerid=divId //ID of master ticker div. Message is contained inside first child of ticker div
this.delay=delay //Delay between msg change, in miliseconds.
this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over ticker (and pause it if it is)
this.pointer=1
this.opacitystring=(typeof fadeornot!="undefined")? "width: 100%; filter:progid:DXImageTransform.Microsoft.alpha(opacity=100); -moz-opacity: 1" : ""
if (this.opacitystring!="") this.delay+=500 //add 1/2 sec to account for fade effect, if enabled
this.opacitysetting=0.2 //Opacity value when reset. Internal use.
document.write('<div id="'+divId+'" class="'+divClass+'"><div style="'+this.opacitystring+'">'+content[0]+'</div></div>')
var instanceOfTicker=this
setTimeout(function(){instanceOfTicker.initialize()}, delay)
}

domticker.prototype.initialize=function(){
var instanceOfTicker=this
this.contentdiv=document.getElementById(this.tickerid).firstChild //div of inner content that holds the messages
document.getElementById(this.tickerid).onmouseover=function(){instanceOfTicker.mouseoverBol=1}
document.getElementById(this.tickerid).onmouseout=function(){instanceOfTicker.mouseoverBol=0}
this.rotatemsg()
}

domticker.prototype.rotatemsg=function(){
var instanceOfTicker=this
if (this.mouseoverBol==1) //if mouse is currently over ticker, do nothing (pause it)
setTimeout(function(){instanceOfTicker.rotatemsg()}, 100)
else{
this.fadetransition("reset") //FADE EFFECT- RESET OPACITY
this.contentdiv.innerHTML=this.content[this.pointer]
this.fadetimer1=setInterval(function(){instanceOfTicker.fadetransition('up', 'fadetimer1')}, 100) //FADE EFFECT- PLAY IT
this.pointer=(this.pointer<this.content.length-1)? this.pointer+1 : 0
setTimeout(function(){instanceOfTicker.rotatemsg()}, this.delay) //update container
}
}

// -------------------------------------------------------------------
// fadetransition()- cross browser fade method for IE5.5+ and Mozilla/Firefox
// -------------------------------------------------------------------

domticker.prototype.fadetransition=function(fadetype, timerid){
var contentdiv=this.contentdiv
if (fadetype=="reset")
this.opacitysetting=0.2
if (contentdiv.filters && contentdiv.filters[0]){
if (typeof contentdiv.filters[0].opacity=="number") //IE6+
contentdiv.filters[0].opacity=this.opacitysetting*100
else //IE 5.5
contentdiv.style.filter="alpha(opacity="+this.opacitysetting*100+")"
}
else if (typeof contentdiv.style.MozOpacity!="undefined" && this.opacitystring!=""){
contentdiv.style.MozOpacity=this.opacitysetting
}
else
this.opacitysetting=1
if (fadetype=="up")
this.opacitysetting+=0.2
if (fadetype=="up" && this.opacitysetting>=1)
clearInterval(this[timerid])
}

function copy_values()
{
	document.getElementById('ship_first_name').value =   document.getElementById('first_name').value;
	document.getElementById('ship_last_name').value =    document.getElementById('last_name').value;
	document.getElementById('ship_address_1').value =    document.getElementById('address_1').value;
	document.getElementById('ship_address_2').value =    document.getElementById('address_2').value;
	document.getElementById('ship_city').value =         document.getElementById('city').value;
	document.getElementById('shipCountrySelect').value = document.getElementById('billCountrySelect').value;
	updateState( 'shipCountrySelect');
	document.getElementById('shipStateSelect').value =   document.getElementById('billStateSelect').value;
	document.getElementById('ship_zip_code').value =     document.getElementById('zip_code').value;
}

/*
	Header Information------------------------------------[Do Not Remove This Header]--
	Title: OO Dom Image Rollover
	Description: This script makes it easy to add rollover/ mousedown
  	effects to any image on the page, including image submit buttons. Automatically
  	preloads images as well. Script works in all DOM capable browsers- IE5+, NS6+,
  	Opera7+.

	Legal: Copyright 2005 Adam Smith
	Author Email Address: ibulwark@hotmail.com
	Date Created: June 6, 2005
	Website: Codevendor.com | eBadgeman.com
	Script featured on Dynamic Drive: http://www.dynamicdrive.com
	-----------------------------------------------------------------------------------
*/

function imageholderclass(){
	this.over=new Array();
	this.down=new Array();
	this.src=new Array();
	this.store=store;

	function store(src, down, over){
		var AL=this.src.length;
		this.src[AL]=new Image(); this.src[AL].src=src;
		this.over[AL]=new Image(); this.over[AL].src=over;
		this.down[AL]=new Image(); this.down[AL].src=down;
	}
}

var ih = new imageholderclass();
var mouseisdown=0;

function preloader(t){
	for(i=0;i<t.length;i++){
		if(t[i].getAttribute('srcover')||t[i].getAttribute('srcdown')){

			storeimages(t[i]);
			var checker='';
			checker=(t[i].getAttribute('srcover'))?checker+'A':checker+'';
			checker=(t[i].getAttribute('srcdown'))?checker+'B':checker+'';

			switch(checker){
			case 'A' : mouseover(t[i]);mouseout(t[i]); break;
			case 'B' : mousedown(t[i]); mouseup2(t[i]); break;
			case 'AB' : mouseover(t[i]);mouseout(t[i]); mousedown(t[i]); mouseup(t[i]); break;
			default : return;
			}

			if(t[i].src){t[i].setAttribute("oldsrc",t[i].src);}
		}
	}
}
function mouseup(t){
	var newmouseup;
	if(t.onmouseup){
		t.oldmouseup=t.onmouseup;
		newmouseup=function(){mouseisdown=0;this.src=this.getAttribute("srcover");this.oldmouseup();}

	}
	else{newmouseup=function(){mouseisdown=0;this.src=this.getAttribute("srcover");}}
	t.onmouseup=newmouseup;
}

function mouseup2(t){
	var newmouseup;
	if(t.onmouseup){
		t.oldmouseup=t.onmouseup;
		newmouseup=function(){mouseisdown=0;this.src=this.getAttribute("oldsrc");this.oldmouseup();}
		}
	else{newmouseup=function(){mouseisdown=0;this.src=this.getAttribute("oldsrc");}}
	t.onmouseup = newmouseup;
}

function mousedown(t){
	var newmousedown;
	if(t.onmousedown){
		t.oldmousedown=t.onmousedown;
		newmousedown=function(){if(mouseisdown==0){this.src=this.getAttribute("srcdown");this.oldmousedown();}}
	}
	else{newmousedown=function(){if(mouseisdown==0){this.src=this.getAttribute("srcdown");}}}
	t.onmousedown=newmousedown;
}

function mouseover(t){
	var newmouseover;
	if(t.onmouseover){
		t.oldmouseover=t.onmouseover;
		newmouseover=function(){this.src=this.getAttribute("srcover");this.oldmouseover();}
	}
	else{newmouseover=function(){this.src=this.getAttribute("srcover");}}
	t.onmouseover=newmouseover;
}

function mouseout(t){
	var newmouseout;
	if(t.onmouseout){
		t.oldmouseout=t.onmouseout;
		newmouseout=function(){this.src=this.getAttribute("oldsrc");this.oldmouseout();}
	}
	else{newmouseout=function(){this.src=this.getAttribute("oldsrc");}}
	t.onmouseout=newmouseout;
}

function storeimages(t){
	var s=(t.getAttribute('src'))?t.getAttribute('src'):'';
	var d=(t.getAttribute('srcdown'))?t.getAttribute('srcdown'):'';
	var o=(t.getAttribute('srcover'))?t.getAttribute('srcover'):'';
	ih.store(s,d,o);
}

function preloadimgsrc(){
	if(!document.getElementById) return;
	var it=document.getElementsByTagName('IMG');
	var it2=document.getElementsByTagName('INPUT');
	preloader(it);
	preloader(it2);
}

if(window.addEventListener){window.addEventListener("load", preloadimgsrc, false);}
else{
	if(window.attachEvent){window.attachEvent("onload", preloadimgsrc);}
	else{if(document.getElementById){window.onload=preloadimgsrc;}}
}

/**
 * SWFObject v1.4.2: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
 *   legal reasons.
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}
if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}
if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}
deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){
if(!document.getElementById){return;}
this.DETECT_KEY=_b?_b:"detectflash";
this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);
this.params=new Object();
this.variables=new Object();
this.attributes=new Array();
if(_1){this.setAttribute("swf",_1);}
if(id){this.setAttribute("id",id);}
if(w){this.setAttribute("width",w);}
if(h){this.setAttribute("height",h);}
if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}
this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();
if(c){this.addParam("bgcolor",c);}
var q=_8?_8:"high";
this.addParam("quality",q);
this.setAttribute("useExpressInstall",_7);
this.setAttribute("doExpressInstall",false);
var _d=(_9)?_9:window.location;
this.setAttribute("xiRedirectUrl",_d);
this.setAttribute("redirectUrl","");
if(_a){this.setAttribute("redirectUrl",_a);}};
deconcept.SWFObject.prototype={setAttribute:function(_e,_f){
this.attributes[_e]=_f;
},getAttribute:function(_10){
return this.attributes[_10];
},addParam:function(_11,_12){
this.params[_11]=_12;
},getParams:function(){
return this.params;
},addVariable:function(_13,_14){
this.variables[_13]=_14;
},getVariable:function(_15){
return this.variables[_15];
},getVariables:function(){
return this.variables;
},getVariablePairs:function(){
var _16=new Array();
var key;
var _18=this.getVariables();
for(key in _18){_16.push(key+"="+_18[key]);}
return _16;
},getSWFHTML:function(){
var _19="";
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");}
_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";
_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";
var _1a=this.getParams();
for(var key in _1a){_19+=key+"=\""+_1a[key]+"\" ";}
var _1c=this.getVariablePairs().join("&");
if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}
_19+="/>";
}else{if(this.getAttribute("doExpressInstall")){
this.addVariable("MMplayerType","ActiveX");}
_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";
_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";
var _1d=this.getParams();
for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}
var _1f=this.getVariablePairs().join("&");
if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}
_19+="</object>";}
return _19;
},write:function(_20){
if(this.getAttribute("useExpressInstall")){
var _21=new deconcept.PlayerVersion([6,0,65]);
if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){
this.setAttribute("doExpressInstall",true);
this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));
document.title=document.title.slice(0,47)+" - Flash Player Installation";
this.addVariable("MMdoctitle",document.title);}}
if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){
var n=(typeof _20=="string")?document.getElementById(_20):_20;
n.innerHTML=this.getSWFHTML();
return true;
}else{
if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}
return false;}};
deconcept.SWFObjectUtil.getPlayerVersion=function(){
var _23=new deconcept.PlayerVersion([0,0,0]);
if(navigator.plugins&&navigator.mimeTypes.length){
var x=navigator.plugins["Shockwave Flash"];
if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}
}else{
try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}
catch(e){try{
var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
_23=new deconcept.PlayerVersion([6,0,21]);
axo.AllowScriptAccess="always";}
catch(e){
if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}
catch(e){}}
if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}
return _23;};
deconcept.PlayerVersion=function(_27){
this.major=_27[0]!=null?parseInt(_27[0]):0;
this.minor=_27[1]!=null?parseInt(_27[1]):0;
this.rev=_27[2]!=null?parseInt(_27[2]):0;
};
deconcept.PlayerVersion.prototype.versionIsValid=function(fv){
if(this.major<fv.major){return false;}
if(this.major>fv.major){return true;}
if(this.minor<fv.minor){return false;}
if(this.minor>fv.minor){return true;}
if(this.rev<fv.rev){return false;}
return true;
};
deconcept.util={getRequestParameter:function(_29){
var q=document.location.search||document.location.hash;
if(q){
var _2b=q.substring(1).split("&");
for(var i=0;i<_2b.length;i++){
if(_2b[i].substring(0,_2b[i].indexOf("="))==_29){
return _2b[i].substring((_2b[i].indexOf("=")+1));}}}
return "";}};
deconcept.SWFObjectUtil.cleanupSWFs=function(){
var _2d=document.getElementsByTagName("OBJECT");
for(var i=0;i<_2d.length;i++){
_2d[i].style.display="none";
for(var x in _2d[i]){if(typeof _2d[i][x]=="function"){_2d[i][x]=null;}}}};
if(typeof window.onunload=="function"){
var oldunload=window.onunload;
window.onunload=function(){
deconcept.SWFObjectUtil.cleanupSWFs();
oldunload();};
}else{window.onunload=deconcept.SWFObjectUtil.cleanupSWFs;}
if(Array.prototype.push==null){
Array.prototype.push=function(_30){
this[this.length]=_30;
return this.length;};}

var getQueryParamValue=deconcept.util.getRequestParameter;
var FlashObject=deconcept.SWFObject; // for legacy support
var SWFObject=deconcept.SWFObject;

var win=null;
		
function NewWindow(mypage,myname,w,h,scroll,pos){
		if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
		if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
		else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
		settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
		win=window.open(mypage,myname,settings);
}
		

var submitcount=0;
function checkSubmit() {

      if (submitcount == 0)
      {
      submitcount++;
      document.Surv.submit();
      }
}


function wordCounter(field, countfield, maxlimit) {
    wordcounter=0;
    for (x=0;x<field.value.length;x++) {
      if (field.value.charAt(x) == " " && field.value.charAt(x-1) != " ")  {wordcounter++}  // Counts the spaces while ignoring double spaces, usually one in between each word.
      if (wordcounter > 250) {field.value = field.value.substring(0, x);}
      else {countfield.value = maxlimit - wordcounter;}
      }
}

function textCounter(field, countfield, maxlimit) {
      if (field.value.length > maxlimit)
        {field.value = field.value.substring(0, maxlimit);}
      else
        {countfield.value = maxlimit - field.value.length;}
}

function submit_subscribe_form()
      {
      alert("Thank you !!");
      document.subscribe.submit();
}
