// JavaScript Document
//In this file please use jQuery instead of using $ because this file is used in marketplace also.
 function addtodesignspace()
{
	if(jQuery('#InspireProducts').val()==undefined)
	{
		var datastring = 'designStudioId='+jQuery("#studioDetail").val()+'&paletteId='+jQuery("#paletteId").val()+'&flag='+jQuery("#flag").val()+'&hidePalette='+jQuery("#hidePalette").val(); 

	}else{

		var inspirProducts=jQuery('#InspireProducts').val();
		var datastring = 'paletteId='+jQuery("#paletteId").val()+'&flag='+jQuery("#flag").val()+'&hidePalette='+jQuery("#hidePalette").val()+'&inspirProducts='+inspirProducts+'&designStudioId='+jQuery("#studioDetail").val();
	}

	jQuery.ajax({
		type: "post",
		url: baseUrl+"/lighting/addpaletteinworkspace",
		data: datastring,
		success:function(responseText){
			jQuery("#changeMessage").html(responseText);
		}
	});
}


function addProDesignstudio()
{
	var datastring = 'designStudioId='+jQuery("#studioDetail1").val()+'&inspirProductSku='+jQuery("#InspirProductSku").val()+'&currentSpaceId='+jQuery("#currentSpaceId").val();
	jQuery.ajax({
		type: "post",
		url: baseUrl+"/lighting/addproductinworkspace",
		data: datastring,
		success:function(responseText){
			jQuery("#changeMessage").html(responseText);
		}
	});
}
function changePosition(val)
{
	if(val!=''){
	var datastring = 'designspcId='+val;
  	jQuery.ajax({
		type: "post",
		url: baseUrl+"/lighting/changedesignpostion",
		data: datastring,
		success:function(responseText){
			jQuery("#workSpace").html(responseText);
		}
	});
	}else{
	 alert('Sorry! Try Again');	
	}
}

function initPHLightBox() {     
	//Get the screen height and width
	var maskHeight = jQuery(document).height();
	var maskWidth = jQuery(window).width();

	//Get the window height and width
	var winH = jQuery(window).height();
	var winW = jQuery(window).width();
		   
	//Set the popup window to center
	jQuery('.light-box-container').css('top',  winH/2-jQuery('.light-box-container').height()/2);
	jQuery('.light-box-container').css('left', winW/2-jQuery('.light-box-container').width()/2);
}
function initCreateDS(cloneWorkspaceID, clonePaletteID, productSKUForPalette) {
	tb_show('Create a New Collection',baseUrl+'/design/addnewdesignstudio?height=393&width=435'
		+ (cloneWorkspaceID ? ('&clonews=' + cloneWorkspaceID) : '')
		+ (clonePaletteID ? ('&clonepal=' + clonePaletteID) : '')
		+ (productSKUForPalette ? ('&productSKUForPalette=' + productSKUForPalette) : ''),
	null);
	return false;
}

//Mage Functions
function mageAddToDS(sku) {
	var url = baseUrl+'/lighting/addprodesignstudio/InspirProductSku/'+sku+'?height=143&width=508';
	tb_show('Product Add to Design Studio',url, null);
	return false;
}
function createPalette(id){
	switch(id)
	{
	case 1:
	  window.location = baseUrl+'/profile/rooms/name/FromScratch';
	  break;
	case 2:
	  window.location = baseUrl+'/profile/rooms/name/ExistingColor';
	  break;
	case 3:
	  break;
	case 4:
	  window.location = baseUrl+'/profile';
	  break;
	}
}

function dragPaletteOnFilmstrip()
{
    $('.palette-filmstrip').addTouch();
	$('.palette-filmstrip').draggable(
	{
		helper:'clone',
		drag:function()
		{	
			$(this).css('z-index','200');
		},
		stop:function()
		{
			$(this).css('z-index','');
		}
	});
}

function dragImageOnFilmstrip()
{
    $('.image-filmstrip').addTouch();
	$('.image-filmstrip').draggable(
	{
		helper:'clone',
		drag:function()
		{	
			$(this).css('z-index','200');
		},
		stop:function()
		{
			$(this).css('z-index','');
		}
	});
}

function dragProductOnFilmstrip()
{
    $('.product-filmstrip').addTouch();
	$('.product-filmstrip').draggable(
	{
		helper:'clone',
		drag:function()
		{	
			$(this).css('z-index','200');
		},
		stop:function()
		{
			$(this).css('z-index','');
		}
	});
}
function showObjAddedmsg(designStudioId) {
	jQuery('#'+designStudioId).append('<span class ="filmstrip-alfha-down"></span><span class="filmstrip-object-msg">Item Added.</span>');
	tb_remove();
	setTimeout( function()
	{
		jQuery('#'+designStudioId).children('.filmstrip-object-msg').remove();
		jQuery('#'+designStudioId).children('.filmstrip-alfha-down').remove();
	}, 5000 );
}
