var SHP = {

	

	start: function() 

	{
		/*
		if (!SHP.ie6() && !SHP.ie7() && !SHP.ie8()) {
			
			// top campaign
			$("#topcampaign").css("top", "-200px").animate({opacity: 0.99}, 500).animate({top: '18px'}, 1000).animate({top: '14px'}, 200).animate({top: '18px'}, 200).animate({top: '16px'}, 200).animate({top: '18px'}, 200);
			
		}	*/	

		

		// Connect Icon to all rel="external" links				

		$('A[rel="external"]').addClass("ext");

		

		// contact

		if ($("#frmContact").attr("name") == "frmContact") {

			SHP.contact();

		}



		// startpage

		if ($("#webshop-overview")) {

			SHP.startpage();			

		}

		

		// references

		if ($("#references")) {

			SHP.references();

		}

		

		// about

		if ($("#cssCompareTable")) {

			SHP.about();	

		}

		

		// forms

		SHP.forms();

		

		// footer

		if ($("#footer")) {

			SHP.footer();

		}

		

		// ie6 issues

		if (SHP.ie6()) {

			$("#footer").hide();

		}

		

		
	},

	

	

	loaded: function()

	{

		if ($("#webshop-overview")) {

			$(".webshop-btn").fadeIn("slow");	

		}

		

		/*/ webshop labels

		if ($("#webshop-ovewview")) {			

			$("#webshop-overview").append('<img class="hide" id="webshop-label-base" src="/Shop/Image/webshop-label-wsbase.png" /><img class="hide" id="webshop-label-medium" src="/Shop/Image/webshop-label-wsmedium.png" /><img class="hide" id="webshop-label-pro" src="/Shop/Image/webshop-label-wspro.png" />');

		

			$('#webshop-label-base').fadeIn('slow', function() {

               $('#webshop-label-medium').fadeIn('slow', function() {

				   $('#webshop-label-pro').fadeIn('slow');

			   });

           });

		}

		*/

	},

	

	forms: function()

	{

		

		// trialshop form

		if ($("#trialshop-form2")) {

			$("#trialshop-form2").submit(function(e){

				

			});

		}

		

		

		// contact form

		if ($("#frmContact")) {

			

			$("#cssPurpleSubmitButton").click(function(e){

		

				var passed = true;

				

				if (SHP.trim($("#sItemName").attr("value")) == '') {

					alert("Ange namn");

					$("#sItemName").focus();

					return false;

				}

	

		

				if (SHP.trim($("#sItemEmailAddress").attr("value")) == '') {

					alert("Ange e-post");

					$("#sItemEmailAddress").focus();

					return false;

				}

	

				if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test($("#sItemEmailAddress").attr("value")))) {

					alert("Ogiltig e-postadress");

					$("#sItemEmailAddress").focus();

					return false;

				}

				

				if (SHP.trim($("#sMsg").attr("value")) == '') {

					alert("Ange ett meddelande");

					$("#sMsg").focus();

					return false;

				}				

		



				

			});

			

		}

		

	},

	

	

	startpage: function()

	{

		

		// home quotes

		if ($("#webshop-quotes")) {

			$('#webshop-quotes').cycle({ fx: 'scrollUp', timeout: 5000 });

			$('#webshop-quotes').show();

		}

		



		// home trialshop textbox

		if ($("#webshop-trialshop-textbox")) {		

			$("#webshop-trialshop-textbox").attr("value", "Ange butiksnamn");

			$("#webshop-trialshop-textbox").focus(function(e){

				if ($("#webshop-trialshop-textbox").attr("value") == "Ange butiksnamn")

					$("#webshop-trialshop-textbox").attr("value", "");

			});

		}	

		

				

		// home webshop boxes

		if ($("#webshop-overview")) {

			$(".webshop-btn").hide();

			$("#webshop-overview").append('<a href="/e-butik" id="webshop-link" title="L&auml;s mer om v&aring;ra plattformar f&ouml;r e-handel"><img src="/Shop/Image/transp1px.gif" width="320" height="250" /></a>');

		

			// cites cycle

			//$('#cite').cycle('fade');		

		

			// mouseovers

			if (!SHP.ie6())

			{



				$("#webshop-btn-price img").hover(

				function () {

				  $(this).attr("src", "/Shop/Image/webshop-btn-price-over.png");

				}, function () {

				  $(this).attr("src", "/Shop/Image/webshop-btn-price.png");

				});

				

				$("#webshop-btn-demo img").hover(

				function () {

				  $(this).attr("src", "/Shop/Image/webshop-btn-demo-over.png");

				}, function () {

				  $(this).attr("src", "/Shop/Image/webshop-btn-demo.png");

				});					

				

				/*

				$("#webshop-title-1").hover(

				function () {

				  $(this).attr("src", "/Shop/Image/webshop-title-1-over.jpg");

				}, function () {

				  $(this).attr("src", "/Shop/Image/webshop-title-1.jpg");

				});	

				

				$("#webshop-title-2").hover(

				function () {

				  $(this).attr("src", "/Shop/Image/webshop-title-2-over.jpg");

				}, function () {

				  $(this).attr("src", "/Shop/Image/webshop-title-2.jpg");

				});	

				

				$("#webshop-title-3").hover(

				function () {

				  $(this).attr("src", "/Shop/Image/webshop-title-3-over.jpg");

				}, function () {

				  $(this).attr("src", "/Shop/Image/webshop-title-3.jpg");

				});					

				*/				

			}

			

		}

	},

	

	contact: function()

	{		

		$("#top").append('<div id="christmas-image"><img src="/Image/christmasballs1.png" alt="God Jul!"/></div>');		

	},

	

	

	references: function()

	{

		

		$(".reference").hover(

		  function() {

			$(this).find("div").fadeIn("fast");

		  }, 

		  function() {

			$(this).find("div").fadeOut("fast");

		  }

		);

		

		

		$(".referenceHref").fancybox({

			'zoomOpacity'			: true,

			'overlayShow'			: true,

			'overlayOpacity'		: 0,

			'frameWidth'			: 700,

			'frameHeight'			: 530,

			'hideOnContentClick': 	false

		});

		

		

		$(".referenceHref2").fancybox({

			'zoomOpacity'			: true,

			'overlayShow'			: true,

			'overlayOpacity'		: 0,

			'frameWidth'			: 900,

			'frameHeight'			: 600,

			'hideOnContentClick': 	true 

		});

		



		

	},

	

	

	about: function()

	{

		



		

		$('.cssFunctionTitle').each(function(element) {	

				// cursor

				$(this).css("cursor", "pointer");							

				// slide

				$(this).click(function(e){

					$obj = $(this).next().next().next().next();

					

					if ($obj.css("display") == "none")

						$obj.slideDown("fast");

					else

						$obj.fadeOut("fast");

				});

		});			

		

		

		$("#divFunctionExpander").html("Visa utökad information");

		$("#divFunctionExpander").click(function(e){

			

			if ($(this).html() == "Visa utökad information")

			{

				$(this).html("Göm utökad information");

				$(this).css("backgroundImage", "url(/Shop/Image/Redesign1/bullet_toggle_plus.gif)");

				$(".cssFunctionExtended").show();

			}

			else

			{

				$(this).html("Visa utökad information");

				$(this).css("backgroundImage", "url(/Shop/Image/Redesign1/bullet_toggle_plus.gif)");				

				$(".cssFunctionExtended").hide();

			}

			

			

			

		});

		

		

	},

	

	

	footer: function()

	{

		// footer quickcontact

		if ($("#quickcontact")) {

			$("#quickcontact-link").click(function(){

				$("#quickcontact").show();

			});

		}

		

		// footer trialshop textbox

		if ($("#webshop-trialshop-textbox2")) {		

			$("#webshop-trialshop-textbox2").attr("value", "Ange butiksnamn");

			$("#webshop-trialshop-textbox2").focus(function(e){

				if ($("#webshop-trialshop-textbox2").attr("value") == "Ange butiksnamn")

					$("#webshop-trialshop-textbox2").attr("value", "");

			});

		}

		

	},

	

	OpenPopupWnd: function(sUrl, iWdtNo, iHgtNo, bIsResizable)

	{

	   var iLeftNo = ((screen.width / 2) - (iWdtNo / 2));

	   var iTopNo = ((screen.height / (2 - iHgtNo)) / (2 - (iHgtNo / 10)));

	   

	   var sFeatures = 'toolbar=yes, location=yes, directories=no, status=yes, menubar=yes, scrollbars='

		  + bIsResizable + ', resizable=' + bIsResizable + ', width=' + iWdtNo + ', height=' + iHgtNo

				+ ',alwaysRaised=yes, left=' + iLeftNo + ', top=' + iTopNo + ',screenX=0, screenY=0';

	   

	   

	   // Close opened window

	   if(oWnd && !oWnd.closed)

	   { oWnd.close(); }

	   

	   

	   

	   oWnd = window.open(sUrl, "OpenPopupWnd", sFeatures);

	   oWnd.location.href = sUrl;

	   oWnd.focus();

	},	

	

	trim: function(sVal) {

		if(sVal != '')

		{

		  while(sVal.substring(0, 1) == ' ')

		  { sVal = sVal.substring(1, sVal.length); }

		  

		  while(sVal.substring(sVal.length - 1, sVal.length) == ' ')

		  { sVal = sVal.substring(0, sVal.length - 1); }

		}

		

		return sVal;

	},

 

		

	

	ie6: function()

	{

		if ($.browser.msie && $.browser.version.substr(0,1)=="6")

			return true;

		else

			return false;

	},
	
	
	ie7: function()

	{

		if ($.browser.msie && $.browser.version.substr(0,1)=="7")

			return true;

		else

			return false;

	},


	ie8: function()

	{

		if ($.browser.msie && $.browser.version.substr(0,1)=="8")

			return true;

		else

			return false;

	}
	

}









// launch jQuery on domready

$(document).ready(function() {



	SHP.start();

	//console.log("SHP.v3.0.js loaded just fine.");

	

});



// launch loaded function on document load

$(document).ready(function() {



	SHP.loaded();

	

});





// var for OpenPopupWnd function

var oWnd = null;

