<?php
/**
 * @name          : Joomla Social Pinboard
 * * @version	  : 2.0
 * @package       : apptha
 * @since         : Joomla 1.5
 * @author        : Apptha - http://www.apptha.com
 * @copyright     : Copyright (C) 2011 Powered by Apptha
 * @license       : http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
 * @abstract      : Social Pinboard Component pinedit view
 * @Creation Date : March 2013
 * @Modified Date : March 2013
 * */
// No direct Access
defined('_JEXEC') or die('Restricted access');
$document = JFactory::getDocument();

$document->addStyleSheet('components/com_wishlogue/css/style.css');
$document->addStyleSheet('components/com_wishlogue/css/public.css');
$document->addStyleSheet('components/com_wishlogue/css/main.css');
$document->addStyleSheet('components/com_wishlogue/css/pinboard.css');
$document->addStyleSheet('components/com_wishlogue/css/reset.css');

$pinsedit = $this->editPins;
$editpinboards = $this->editPinboards;
$updatePins = $this->updatePins;
$categoryNames = $this->categoryNames;
$subcatalogueList = $this->subcatalogueList;

$user = JFactory::getUser();
$userId = $user->id;
if ($userId != '' && $userId != '0') {


	if (count($pinsedit) == 0) {
		?>
		<div id="login_error_msg">
			<?php echo JText::_('COM_WISHLOGUE_UNABLE_TO_EDIT_THE_PIN'); ?>
		</div>
		<?php
	} else {
		?>
		<div id="pin_edit">
			<!--<form method="post" action="">-->
				<form method="post" action="" onsubmit="return validate_wishedit();">
				<h3 class="edit-board-title"><?php echo JText::_('COM_WISHLOGUE_EDIT_PIN'); ?></h3>

				<ul class="edit-board" style="float: left;">

					<!-- rgs. -->
					<!-- Item -->
					<li>
						<label><?php echo JText::_('COM_WISHLOGUE_WISH_ITEM'); ?></label>
						<input class="edit-link"  type="text" name="wish_item" id="wish_item" value="<?php if (!empty($pinsedit[0]->wish_item)) {
			echo $pinsedit[0]->wish_item;
		};
		?>"/>
						<div class='wish_edit_invalid_field' id='wish_item_invalid' style='display: none;'>
							<label>&nbsp;</label>
		<?php echo JText::_('COM_WISHLOGUE_WISH_ITEM') . JText::_('COM_WISHLOGUE_INVALID_MANDATORY_FIELD_MUST_VALID'); ?>
						</div>
					</li>
					<!-- rgs.. -->

					<li style='display: none;'>
						<label><?php echo JText::_('COM_WISHLOGUE_LINK'); ?></label>
						<input class="edit-link"  type="text" name="pinlink" id="pinlink" value="<?php
				if (!empty($pinsedit[0]->pin_url)) {
					echo $pinsedit[0]->pin_url;
				};
		?>"/>
						<div class='wish_edit_invalid_field' id='wish_link_invalid' style='display: none;'>
							<label>&nbsp;</label>
		<?php echo JText::_('COM_WISHLOGUE_LINK') . JText::_('COM_WISHLOGUE_INVALID_MANDATORY_FIELD_MUST_VALID'); ?>
						</div>
					</li>

					<!-- rgs. all catalogues. -->
					<li>
						<label><?php echo JText::_('COM_WISHLOGUE_BOARD'); ?></label>
						<select name="board_category" id="board_category" onchange="catalogueChanged(this)" class="board_category_select_style">
							<?php foreach ($categoryNames as $categoryName) { ?>
								<option value="<?php echo $categoryName->category_id; ?>" <?php if ( $pinsedit[0]->pin_category_id == $categoryName->category_id ) { echo 'selected'; } ?> >
							<?php echo ucfirst($categoryName->category_name) . '*' . strtoupper(JText::_('COM_WISHLOGUE_LOGUES')); ?>
								</option>
							<?php } ?>
						</select>
					</li>
					<!-- rgs. all catalogues.. -->

					<!-- rgs. subcatalogues. -->
					<li>
						<label><?php echo JText::_('COM_WISHLOGUE_SUBCATALOGUE'); ?></label>
						<select name="boardname" id="boardname" onchange="changeselected(this)" class="board_category_select_style_bd">
								<?php foreach ($subcatalogueList as $boardName) { ?>
								<option value="<?php echo $boardName->subcatalogue_id; ?>" <?php 
									if ('1*' . $pinsedit[0]->pin_board_id == $boardName->subcatalogue_id || '2*' . $pinsedit[0]->pin_board_id == $boardName->subcatalogue_id) {
										echo 'selected=selected';
									}
								?>><?php  echo $boardName->subcatalogue_name;  ?></option>
								<?php }  ?>
						</select>
						<!--<span class="down-arrow"></span>-->
						<div class='wish_edit_invalid_field' id='wish_subcatalogue_invalid_field' style='display: none;'>
							<label>&nbsp;</label>
							<?php echo JText::_('COM_WISHLOGUE_PLEASE_ADD_SUBCATALOGUE'); ?>
						</div>
					</li>
					<!-- rgs. subcatalogues.. -->

					<div id='catalogue_selection_display' style='display: none;'>	
						<li>
							<label><?php echo JText::_('COM_WISHLOGUE_BOARD'); ?></label>
							<input style="color:#C9C8C8" class="edit-link" type="text" name="uploadboardtxt" id="uploadboardtxt" onFocus="onFocusMenu(this, '<?php echo JText::_('COM_WISHLOGUE_PLEASE_ENTER_BOARD_NAME') ?>');" onBlur="onBlurEvent(this, '<?php echo JText::_('COM_WISHLOGUE_PLEASE_ENTER_BOARD_NAME') ?>');" value="<?php echo JText::_('COM_WISHLOGUE_PLEASE_ENTER_BOARD_NAME') ?>" />
							<input type="button" class="save-editpin" onclick="addnewmenuboard(<?php echo $user->id; ?>)" value="<?php echo JText::_('COM_WISHLOGUE_CREATE'); ?>" />
							<div id="boardError" class="pin-it-error" style="clear:both;"></div>
						</li>
					</div>

					<!-- rgs. -->

		            <!-- Retailer -->
					<li>
						<label><?php echo JText::_('COM_WISHLOGUE_WISH_RETAILER'); ?></label>
						<input class="edit-link"  type="text" name="wish_retailer" id="wish_retailer" value="<?php if (!empty($pinsedit[0]->wish_retailer)) {
			echo $pinsedit[0]->wish_retailer;
		};
		?>"/>
						<div class='wish_edit_invalid_field' id='wish_retailer_invalid' style='display: none;'>
							<label>&nbsp;</label>
							   <?php echo JText::_('COM_WISHLOGUE_WISH_RETAILER') . JText::_('COM_WISHLOGUE_INVALID_MANDATORY_FIELD_MUST_VALID'); ?>
						</div>
					</li>

					<!-- Product URL -->
					<li>
						<label><?php echo JText::_('COM_WISHLOGUE_WISH_PRODUCT_URL'); ?></label>
						<input class="edit-link"  type="text" name="wish_product_url" id="wish_product_url" value="<?php if (!empty($pinsedit[0]->wish_product_url)) {
						   echo $pinsedit[0]->wish_product_url;
					   };
					   ?>"/>
						<div class='wish_edit_invalid_field' id='wish_producturl_invalid' style='display: none;'>
							<label>&nbsp;</label>
						<?php echo JText::_('COM_WISHLOGUE_WISH_PRODUCT_URL') . JText::_('COM_WISHLOGUE_INVALID_MANDATORY_FIELD_MUST_VALID'); ?>
						</div>
					</li>

		            <!-- Currency -->
					<li>
						<label><?php echo JText::_('COM_WISHLOGUE_WISH_CURRENCY'); ?></label>
						<!-- <select name="wish_currency" id="wish_currency">
						<?php
						// $currencyList = $this->currencyList;
						// foreach ( $currencyList as $curRency ) {
						// if(isset($pinsedit[0]->wish_currency)) {
						// if( $pinsedit[0]->wish_currency == $curRency->currency_val ) {
						// echo '<option selected value="' . $curRency->currency_val . '">' . $curRency->currency_text . '</option>';
						// } else {
						// echo '<option value="' . $curRency->currency_val . '">' . $curRency->currency_text . '</option>';
						// }
						// }
						// }
						?>
						</select> -->
						<input class="edit-link" type="text" name='wish_currency_dum' id='wish_currency_dum' value="USD$" readonly='true' /></p>
						<input type="hidden" name="wish_currency" id="wish_currency" value="USD" />

						<div class='wish_edit_invalid_field' id='wish_currency_invalid' style='display: none;'>
							<label>&nbsp;</label>
							<?php echo JText::_('COM_WISHLOGUE_WISH_CURRENCY') . JText::_('COM_WISHLOGUE_INVALID_MANDATORY_FIELD_MUST_VALID'); ?>
						</div>
					</li>

		            <!-- Price -->
					<li>
						<label><?php echo JText::_('COM_WISHLOGUE_WISH_PRICE'); ?></label>
						<input class="edit-link" type="text" name="price" id="price" value="<?php if (isset($pinsedit[0]->price)) {
								echo $pinsedit[0]->price;
							};
							?>"/>
						<div class='wish_edit_invalid_field' id='wish_price_invalid' style='display: none;'>
							<label>&nbsp;</label>
		<?php echo JText::_('COM_WISHLOGUE_WISH_PRICE') . JText::_('COM_WISHLOGUE_INVALID_MANDATORY_FIELD_MUST_VALID'); ?>
						</div>
					</li>

		            <!-- Quantity -->
					<li>
						<label><?php echo JText::_('COM_WISHLOGUE_WISH_QUANTITY'); ?></label>
						<input class="edit-link" readonly="true" type="text" name="wish_quantity" id="wish_quantity" value="<?php if (!empty($pinsedit[0]->wish_quantity)) {
			echo $pinsedit[0]->wish_quantity;
		}
		?>"/>
						<div class='wish_edit_invalid_field' id='wish_quantity_invalid' style='display: none;'>
							<label>&nbsp;</label>
		<?php echo JText::_('COM_WISHLOGUE_WISH_QUANTITY') . JText::_('COM_WISHLOGUE_INVALID_MANDATORY_FIELD_MUST_VALID'); ?>
						</div>
					</li>

		            <!-- Size -->
					<li>
						<label><?php echo JText::_('COM_WISHLOGUE_WISH_SIZE'); ?></label>
						<input class="edit-link"  type="text" name="wish_size" id="wish_size" value="<?php if (!empty($pinsedit[0]->wish_size)) {
			echo $pinsedit[0]->wish_size;
		};
		?>"/>
						<div class='wish_edit_invalid_field' id='wish_size_invalid' style='display: none;'>
							<label>&nbsp;</label>
		<?php echo JText::_('COM_WISHLOGUE_WISH_SIZE') . JText::_('COM_WISHLOGUE_INVALID_MANDATORY_FIELD_MUST_VALID'); ?>
						</div>
					</li>

		            <!-- Style -->
					<li>
						<label><?php echo JText::_('COM_WISHLOGUE_WISH_STYLE'); ?></label>
						<input class="edit-link"  type="text" name="wish_style" id="wish_style" value="<?php if (!empty($pinsedit[0]->wish_style)) {
						echo $pinsedit[0]->wish_style;
					};
					?>"/>
						<div class='wish_edit_invalid_field' id='wish_style_invalid' style='display: none;'>
							<label>&nbsp;</label>
		<?php echo JText::_('COM_WISHLOGUE_WISH_STYLE') . JText::_('COM_WISHLOGUE_INVALID_MANDATORY_FIELD_MUST_VALID'); ?>
						</div>
					</li>

		            <!-- Color -->
					<li>
						<label><?php echo JText::_('COM_WISHLOGUE_WISH_COLOR'); ?></label>
						<input class="edit-link"  type="text" name="wish_color" id="wish_color" value="<?php if (!empty($pinsedit[0]->wish_color)) {
						echo $pinsedit[0]->wish_color;
					};
					?>"/>
						<div class='wish_edit_invalid_field' id='wish_color_invalid' style='display: none;'>
							<label>&nbsp;</label>
						<?php echo JText::_('COM_WISHLOGUE_WISH_COLOR') . JText::_('COM_WISHLOGUE_INVALID_MANDATORY_FIELD_MUST_VALID'); ?>
						</div>
					</li>

					<!-- rgs.. -->

					<li>
						<label><?php echo JText::_('COM_WISHLOGUE_WISH_NOTES'); ?></label>
						<textarea name="description_pin_edit" id="description_pin_edit" class="" ><?php
				   if (!empty($pinsedit[0]->pin_description)) {
					   echo $pinsedit[0]->pin_description;
				   }
				   ?></textarea>
						<div class='wish_edit_invalid_field' id='wish_notes_invalid' style='display: none;'>
							<label>&nbsp;</label>
					<?php echo JText::_('COM_WISHLOGUE_WISH_NOTES') . JText::_('COM_WISHLOGUE_INVALID_MANDATORY_FIELD_MUST_VALID'); ?>
						</div>
					</li>

					<!-- rgs. -->
					<!-- Grant Status -->
					<li>
						<label><?php echo JText::_('COM_WISHLOGUE_WISH_STATUS'); ?></label>
						<input class="edit-link" readonly="true" type="text" name="wish_current_staus" id="wish_current_staus" value="<?php if (!empty($pinsedit[0]->wish_status)) {
						echo $pinsedit[0]->wish_status;
					}; ?>"/>
					</li>

					<!-- Change Grant Status -->
					<li>
						<label>&nbsp;</label>
						<?php
						if ( $userId != $pinsedit[0]->wish_status_user ) {
						?>
						<div class="owngrant">
						<input type="checkbox" name="wish_owngrant" value="ON" id="owngrant" class="radio-wish-grant">
						<?php echo '<span class="span-owngrant">' . JText::_('COM_WISHLOGUE_GRANT_OWN_WISH') . '</span>'; ?>
						</div>
						<?php }
						if( $pinsedit[0]->wish_status != 'Not Granted' ) {
						?>
						<div class="notgrant">
						<input type="checkbox" name="wish_notgrant" value="ON" id="notgrant" class="radio-wish-grant">
						<?php
						echo '<span class="span-notgrant">' . JText::_('COM_WISHLOGUE_UNGRANT_WISH') . '</span>'; ?></div>
						<?php } ?>
					</li>
					<!-- rgs.. -->

		            <li>
		                <label>&nbsp;</label>
		                <a href="#" class="delet_pin" onclick="Modal.show('pinDiv');
										return false" class="delete-board">Delete</a>
		                <input type="submit"  name="SavePin" id="SavePin" value="<?php echo JText::_('COM_WISHLOGUE_SAVE_PIN'); ?>" class="save-editpin"/>
		            </li>
		        </ul>

		    </form>
		    <div class="PinEditPreview" style="padding:0;">
				<?php
				$Wish_product_url =  $pinsedit[0]->wish_product_url;
				if( strpos($Wish_product_url, 'http://') === false && strpos($Wish_product_url, 'https://') === false ) {
					$Wish_product_url = 'http://' . $Wish_product_url;
				}
				?>
				<a target="_blank" href="<?php echo $Wish_product_url; ?>" >

		<?php
		if ($pinsedit[0]->link_type == 'youtube' || $pinsedit[0]->link_type == 'vimeo') {
			$src_path = $pinsedit[0]->pin_image;
		} else {
			$src_path = JURI::base() . "images/wishlogue/wish_medium/" . rawurlencode($pinsedit[0]->pin_image);
		}
		?>
					<div class="ImagePicker" style="width: 192px;margin-top: 0;padding: 0 10px 0 0px;">

						<div id="PinEditPreview" style="padding: 10px;width: 182px;">
							<img src="<?php echo $src_path; ?>" alt="pin_img" style="max-width:182px;" />
						</div>

					</div>
					<div style="padding: 10px;"><?php echo $pinsedit[0]->pin_description; ?></div>
			</a></div>


			<div id="pinDiv" class="ModalContainer">
				<div class="modal wide delete-pin-pop">
					<div class="header lg">
						<a href="#" class="close" onclick="Modal.close('pinDiv');
										return false;"><strong>Close</strong><span></span></a>
						<h2><?php echo JText::_('COM_WISHLOGUE_DELETE_A_PIN') ?></h2>
					</div>
					<p style="font-size: 18px;font-weight: bold;"><?php echo JText::_('COM_WISHLOGUE_PIN_DELETE_ALERT'); ?></p>
					<form action="" method="post">
						<input type="submit" name="delete_pin" id="delete_pin" value="<?php echo JText::_('COM_WISHLOGUE_DELETE_PIN'); ?>"/>
						<input type="button" onclick="Modal.close('pinDiv');
										return false" name="no_delete" id="no_delete" value="<?php echo JText::_('COM_WISHLOGUE_CANCEL'); ?>"/>
					</form>
				</div>
			</div>
			<style type="text/css">.ImagePicker .price.visible {left: -35px;}</style>
		</div>
		<?php
	}
} else {
	$redirectUrl = JRoute::_('index.php?option=com_wishlogue&view=people', false);
	$app = JApplication::getInstance();
	$app->redirect($redirectUrl);
}
?>

<script type="text/javascript">
							///rgs.

							function changeselected(obj)
							{
//								var strUser = obj.options[obj.selectedIndex].value;
//								var upload_board = strUser.split("*");
//
//								document.getElementById('catalogue_selection_display').style.display = 'none';
//								if (upload_board[1] == 0) {
//									document.getElementById('catalogue_selection_display').style.display = '';
//								}
							}
							function catalogueChanged(obj)
							{
								var upload_board = document.getElementById("boardname");
								for (i = upload_board.options.length - 1; i >= 0; i--) {
									upload_board.options[i] = null;
								}
								//document.getElementById('catalogue_selection_display').style.display = 'none';

								if (obj.options[obj.selectedIndex].value > 0) {
									var data_file = '<?php echo JUri::root(); ?>/index.php?option=com_wishlogue&view=ajaxcontrol&task=subcatalogueList&catId=' + obj.options[obj.selectedIndex].value;
									var http_request = new XMLHttpRequest();
									try {
										http_request = new XMLHttpRequest();
									} catch (e) {
										try {
											http_request = new ActiveXObject("Msxml2.XMLHTTP");
										} catch (e) {
											try {
												http_request = new ActiveXObject("Microsoft.XMLHTTP");
											} catch (e) {
												alert("Your browser broke!");
												return false;
											}
										}
									}
									http_request.onreadystatechange = function()
									{
										if (http_request.readyState == 4)
										{
											var jsonObj = JSON.parse(http_request.responseText);
											var x = document.getElementById("boardname");

											var option = document.createElement("option");
											option.text = 'Select SubCatalogue';
											option.value = '3*0';
											x.add(option, 0);

											for (i in jsonObj) {
												var option = document.createElement("option");
												option.text = jsonObj[i].subcatalogue_name;
												option.value = jsonObj[i].subcatalogue_id;
												x.add(option);
											}

//											if (Object.keys(jsonObj).length == 0) {
//												document.getElementById('catalogue_selection_display').style.display = '';
//											} else {
//												document.getElementById('catalogue_selection_display').style.display = 'none';
//											}
										}
									}
									http_request.open("GET", data_file, true);
									http_request.send();
								}
							}

							function validate_wishedit()
							{

								var upload_board_w = document.getElementById('boardname').value;
								var upload_board = upload_board_w.split("*");

								if (upload_board[1] == '' || upload_board[1] == null || upload_board[1] == 0) {
									document.getElementById('boardname').focus();
									//alert("<?php// echo JText::_('COM_WISHLOGUE_PLEASE_ADD_SUBCATALOGUE'); ?>");
									document.getElementById('wish_subcatalogue_invalid_field').style.display = '';
									return false;
								}
								
								var wishPrice = document.getElementById('price').value.trim();
								var wishQuantity = document.getElementById('wish_quantity').value.trim();
								var wishItem = document.getElementById('wish_item').value.trim();
								var wishRetailer = document.getElementById('wish_retailer').value.trim();

								if (wishItem == '' || wishItem == '<?php echo JText::_('COM_WISHLOGUE_WISH_ITEM'); ?>') {
									document.getElementById('wish_item').focus();
									document.getElementById('wish_item_invalid').style.display = '';
									return false;
								}
								if (wishRetailer == '' || wishRetailer == '<?php echo JText::_('COM_WISHLOGUE_WISH_RETAILER'); ?>') {
									document.getElementById('wish_retailer').focus();
									document.getElementById('wish_retailer_invalid').style.display = '';
									return false;
								}
								if ( wishPrice == '' || isNaN(wishPrice) ) {
									document.getElementById('price').focus();
									document.getElementById('wish_price_invalid').style.display = '';
									return false;
								}
								if ( wishQuantity == '' || isNaN(wishQuantity) ) {
									document.getElementById('wish_quantity').focus();
									document.getElementById('wish_quantity_invalid').style.display = '';
									return false;
								}

								return true;

								if (typeof String.prototype.trim !== 'function') {
									String.prototype.trim = function() {
										return this.replace(/^\s+|\s+$/g, '');
									}
								}
								document.getElementById('wish_item_invalid').style.display = 'none';
								document.getElementById('wish_retailer_invalid').style.display = 'none';
								document.getElementById('wish_producturl_invalid').style.display = 'none';
								document.getElementById('wish_price_invalid').style.display = 'none';
								document.getElementById('wish_quantity_invalid').style.display = 'none';
								document.getElementById('wish_size_invalid').style.display = 'none';
								document.getElementById('wish_style_invalid').style.display = 'none';
								document.getElementById('wish_color_invalid').style.display = 'none';
								document.getElementById('wish_notes_invalid').style.display = 'none';
								document.getElementById('wish_link_invalid').style.display = 'none';

								// var wishLink = document.getElementById('pinlink').value.trim();
								var wishProductURL = document.getElementById('wish_product_url').value.trim();
								var wishSize = document.getElementById('wish_size').value.trim();
								var wishStyle = document.getElementById('wish_style').value.trim();
								var wishColor = document.getElementById('wish_color').value.trim();
								var wishNotes = document.getElementById('description_pin_edit').value.trim();

								if (wishItem == '' || wishItem == '<?php echo JText::_('COM_WISHLOGUE_WISH_ITEM'); ?>') {
									document.getElementById('wish_item').focus();
									document.getElementById('wish_item_invalid').style.display = '';
									return false;
								}
								if (wishRetailer == '' || wishRetailer == '<?php echo JText::_('COM_WISHLOGUE_WISH_RETAILER'); ?>') {
									document.getElementById('wish_retailer').focus();
									document.getElementById('wish_retailer_invalid').style.display = '';
									return false;
								}
								if (wishProductURL == '' || wishProductURL == '<?php echo JText::_('COM_WISHLOGUE_WISH_PRODUCT_URL'); ?>' || is_valid_url(wishProductURL) == null) {
									document.getElementById('wish_product_url').focus();
									document.getElementById('wish_producturl_invalid').style.display = '';
									return false;
								}
								if (wishPrice == '' || wishPrice == '<?php echo JText::_('COM_WISHLOGUE_WISH_PRICE'); ?>' || isNaN(wishPrice)) {
									document.getElementById('price').focus();
									document.getElementById('wish_price_invalid').style.display = '';
									return false;
								}
								if (wishQuantity == '' || wishQuantity == '<?php echo JText::_('COM_WISHLOGUE_WISH_QUANTITY'); ?>' || isNaN(wishQuantity)) {
									document.getElementById('wish_quantity').focus();
									document.getElementById('wish_quantity_invalid').style.display = '';
									return false;
								}
								if (wishSize == '' || wishSize == '<?php echo JText::_('COM_WISHLOGUE_WISH_SIZE'); ?>') {
									document.getElementById('wish_size').focus();
									document.getElementById('wish_size_invalid').style.display = '';
									return false;
								}
								if (wishStyle == '' || wishStyle == '<?php echo JText::_('COM_WISHLOGUE_WISH_STYLE'); ?>') {
									document.getElementById('wish_style').focus();
									document.getElementById('wish_style_invalid').style.display = '';
									return false;
								}
								if (wishColor == '' || wishColor == '<?php echo JText::_('COM_WISHLOGUE_WISH_COLOR'); ?>') {
									document.getElementById('wish_color').focus();
									document.getElementById('wish_color_invalid').style.display = '';
									return false;
								}
								if (wishNotes == '' || wishNotes == '<?php echo JText::_('COM_WISHLOGUE_WISH_NOTES'); ?>') {
									document.getElementById('description_pin_edit').focus();
									document.getElementById('wish_notes_invalid').style.display = '';
									return false;
								}

								return true;
							}
							///rgs..
</script>

<script type="text/javascript">
	var pinID = "118";
	scr(document).ready(function() {
		EditPin.setup();
	});
</script>

<script>
	///rgs.
	jQuery(function()
	{
		jQuery('#notgrant').click(function() {
			if (jQuery('#notgrant').prop('checked')) {
				jQuery('#owngrant').prop('checked', false);
			}
		});
		jQuery('#owngrant').click(function() {
			if (jQuery('#owngrant').prop('checked')) {
				jQuery('#notgrant').prop('checked', false);
			}
		});
	});
	///rgs..
</script>